discord

Discord Python Rewrite - Account Generator

蓝咒 提交于 2021-02-11 13:36:27
问题 I Want to make a discord account generator using python and json, i can make it gen but i cant make it delete the account after genned, please help. The code: @client.command() async def gentest(ctx): genembed = discord.Embed( title="Minecraft NFA", colour=discord.Color.green() ) with open('alts.json', 'r') as f: alts = json.load(f) genembed.add_field(name="Account:", value=random.choice(alts), inline=False) with open('alts.json', 'w') as f: alts = alts.pop(alts) await ctx.author.send(embed

Discord py more than one tasks.loop at the same time?

柔情痞子 提交于 2021-02-11 13:30:49
问题 How can I have more than one loop running ate the same time using the same function but using different parameters like: @tasks.loop(seconds = 10) async def loop(name): Print(name) loop.start("Jon") loop.start("Joseph") Is this how u pass parameters to loops? 回答1: You need to create a new Loop object for each loop. You can do this by using regular function calling repeatedly instead of the decorator: async def loop(name): print(name) names = ["Jon", "Joseph"] loops = {name: tasks.loop(seconds

Discord py more than one tasks.loop at the same time?

房东的猫 提交于 2021-02-11 13:30:39
问题 How can I have more than one loop running ate the same time using the same function but using different parameters like: @tasks.loop(seconds = 10) async def loop(name): Print(name) loop.start("Jon") loop.start("Joseph") Is this how u pass parameters to loops? 回答1: You need to create a new Loop object for each loop. You can do this by using regular function calling repeatedly instead of the decorator: async def loop(name): print(name) names = ["Jon", "Joseph"] loops = {name: tasks.loop(seconds

Discord.py user.block/user.send_friend_request: Error 403/Forbidden How do I give the bot permission to send friend requests and block users?

[亡魂溺海] 提交于 2021-02-11 12:50:12
问题 I'm currently trying to create a block user and send friend request command. However, I've hit a wall. It seems like the bot doesn't have permission or authorization to my account so it can't send friend requests or block users. How do I give it the permissions? Or maybe it isn't possible at all? Please let me know, I'd really appreciate it :> My current code for the commands is below: @client.command() async def unfriend(ctx, *, user: discord.User): await user.remove_friend() await ctx.send(

Discord.js guild.roles.cache.find returning undefined

余生颓废 提交于 2021-02-11 12:46:08
问题 Im trying to assign code a discord bot to give someone a role whenever they enter a server. This is my code right now: client.on('guildMemberAdd', (member) => { let role = guild.roles.cache.find(r => r.name === "Admin"); console.log(role); if(!role){ console.log("Role doesen't exist."); } member.roles.add(role); }); I tried running it, and this line executed: console.log("Role doesen't exist."); . I then went on to print the role variable, and it was undefined. What's the problem? 回答1: First

How to fix “discord.errors.ClientException: Command kick is already registered.” error?

不打扰是莪最后的温柔 提交于 2021-02-11 12:40:26
问题 I'm making a discord bot in discord.py that kicks any member that sends a certain string, but I get the error "discord.errors.ClientException: Command kick is already registered." bot = commands.Bot(command_prefix=',') @client.event async def on_message(message): if message.author == client.user: return if "kick me"in message.content: @bot.command(name="kick", pass_context=True) @has_permissions(kick_members=True) async def _kick(ctx, member: Member): await bot.kick(member) Instead of kicking

Making discord bot mention someone

不打扰是莪最后的温柔 提交于 2021-02-11 12:40:22
问题 How do I make my bot mention someone on the server? module.exports = { name: 'mention', description: 'this is a mention command!', execute(message) { mention = message.mentions.users.first(); message.channel.send('Hello' + mention); }, }; I thought it would work but it doesn't. Is there another way to mention someone? 回答1: message.mentions.users.first() returns an object, which is why it's not working. This is the correct way to mention someone: mention = message.mentions.users.first();

How to fix “discord.errors.ClientException: Command kick is already registered.” error?

为君一笑 提交于 2021-02-11 12:40:16
问题 I'm making a discord bot in discord.py that kicks any member that sends a certain string, but I get the error "discord.errors.ClientException: Command kick is already registered." bot = commands.Bot(command_prefix=',') @client.event async def on_message(message): if message.author == client.user: return if "kick me"in message.content: @bot.command(name="kick", pass_context=True) @has_permissions(kick_members=True) async def _kick(ctx, member: Member): await bot.kick(member) Instead of kicking

Making discord bot mention someone

两盒软妹~` 提交于 2021-02-11 12:39:12
问题 How do I make my bot mention someone on the server? module.exports = { name: 'mention', description: 'this is a mention command!', execute(message) { mention = message.mentions.users.first(); message.channel.send('Hello' + mention); }, }; I thought it would work but it doesn't. Is there another way to mention someone? 回答1: message.mentions.users.first() returns an object, which is why it's not working. This is the correct way to mention someone: mention = message.mentions.users.first();

discord.js say command actually says “say”

人盡茶涼 提交于 2021-02-11 12:18:55
问题 I've never had a problem with the say command until I start using modules and cleaned up my code but since I have few my commands have bugged. I'm trying to figure out why it is saying the command. const commandFiles = fs .readdirSync("./commands/") .filter(file => file.endsWith(".js")); for (const file of commandFiles) { const command = require(`./commands/${file}`); bot.commands.set(command.name, command); } bot.on("message", async message => { if (!message.content.startsWith(PREFIX))