如上所述。我正在尝试为Discord机器人创建一个临时的静音命令。我遇到的问题是它创建了静音角色,但是即使我更改了权限,用户仍然可以编写消息。 最重要的是,我收到以下弃用警告:
(节点:15956)DeprecationWarning:Collection#find:传递函数 代替
df = pd.read_fwf('file.csv', header=[0,1])
df.columns = [y for x in df.columns for y in x if not 'Unnamed' in y]
#replace missing values by first column
df.iloc[:, 0] = df.iloc[:, 0].ffill().astype(int)
#set first 2 columns to MultiIndex
df = df.set_index(df.columns[:2].tolist())
print (df)
col1 col2
idx1 idx2
1 1 0.1234 0.2345
2 0.4567 0.2345
3 0.1244 0.5332
2 1 0.4213 0.5233
2 0.5423 0.5423
3 0.5235 0.6233
答案 0 :(得分:0)
我发现了问题,就像您说的那样,这是权限。最重要的是,我应该进行了更改:
let muterole = message.guild.roles.find(`name`, "muted");
到以下内容:
let muterole = message.guild.roles.find(muterole => muterole.name === "muted");
答案 1 :(得分:0)
我在您的脚本中发现了一些错误,因此我为您修复了该错误
//!tempmute @user 1s/m/h/d
let tomute = message.guild.member(message.mentions.users.first() ||
message.guild.members.get(args[0])); if(!tomute) return
message.reply("Couldn't find user.");
if(tomute.hasPermission("MANAGE_MESSAGES")) return
message.reply("Can't mute them!"); let muterole =
message.guild.roles.find(muterole => muterole.name === "muted");
//start of create role if(!muterole){
try{
muterole = await message.guild.createRole({
name: "muted",
color: "#000000",
permissions:[]
})
message.guild.channels.forEach(async (channel, id) => {
await channel.overwritePermissions(muterole, {
SEND_MESSAGES: false,
ADD_REACTIONS: false
});
});
}catch(e){
console.log(e.stack);
} } //end of create role let mutetime = args[1]; if(!mutetime) return message.reply("You didn't specify a time!");
await(tomute.addRole(muterole.id)); message.reply(`<@${tomute.id}>
has been muted for ${message(message(mutetime))}`);
setTimeout(function(){
tomute.removeRole(muterole.id);
message.channel.send(`<@${tomute.id}> has been unmuted!`); }, message (mutetime));
//end of module }
module.exports.help = { name: "tempmute" }