discord

How to make a command case insensitive in discord.py

橙三吉。 提交于 2019-11-28 08:55:30
问题 How would one make a command case-insensitive without adding many aliases for different capitalizations like this: @bot.command(pass_context = True, name = 'test', aliases=['Test', 'tEst', 'teSt', 'tesT', 'TEst', 'TeSt', 'TesT', 'tESt', 'tEsT']) async def test(self, ctx): #do stuff 回答1: On the rewrite branch, commands.Bot accepts a case_insensitive parameter bot = commands.Bot(command_prefix='!', case_insensitive=True) Note that there is a performance loss when using this feature. 回答2: I am

Discord.py silence command

半城伤御伤魂 提交于 2019-11-28 08:53:38
问题 I have been asking loads of questions lately about discord.py and this is one of them. Sometimes there are those times when some people spam your discord server but kicking or banning them seems too harsh. I had the idea for a silence command which would delete every new message on a channel for a given amount of time. My code so far is: @BSL.command(pass_context = True) async def silence(ctx, lenghth = None): if ctx.message.author.server_permissions.administrator or ctx.message.author.id ==

Cooldown For Command On Discord Bot Python

浪子不回头ぞ 提交于 2019-11-28 06:29:44
问题 @client.command(pass_context = True) async def getalt(ctx): msg = ["gabrielwarren2000@gmail.com:Cyber123", "leandroriveros123@gmail.com:culillo123", "albesi8@msn.com:Albakortoci1", "dryden6@yahoo.ca:toysale22", "nichlas00100@gmail.com:nich918273645", "lodevanveen@gmail.com:Lodelode1", "kylefielding2011@gmail.com:emolover123", "rubbst3in@gmail.com:rube541632789mk", "jasonfryckman@ymail.com:fryckman22", "NickSaya1@hotmail.com:blackout541", "devinquan@yahoo.com:ploopy101"] await client.send

Discord python on role grant event

徘徊边缘 提交于 2019-11-28 06:15:20
问题 So i've been trying to get the bot to announce whenever a member gets a role granted, i know that this code may not make sense at all, but that's why i'm asking: How could i do it? @bot.event async def on_member_update(before, after): if str(after.roles) == 'android': fmt = "{0.mention} your role request has been accepted! :confetti_ball: You've been granted the role '{1}'" await bot.send_message(bot.get_channel('495285593711050754'), fmt.format(member, after.roles.name)) print(colored(

discord.py bot getting cooldown time remaining of command

我与影子孤独终老i 提交于 2019-11-28 02:13:00
问题 I'm working on a python based discord bot that has the following command @client.command(name="Mine", description="Mine daily.", brief="Mine daily.", aliases=['mine', 'm'], pass_context=True) @commands.cooldown(1, 30, commands.BucketType.user) async def mine(ctx, arg): <content> But when users hit the 30 second rate limit of the command it outputs the error to the python shell Ignoring exception in command Mine Traceback (most recent call last): File "C:\Users\raner\AppData\Local\Programs

Discord Bot Can't Get Channel by Name

拈花ヽ惹草 提交于 2019-11-28 01:57:04
I have been making a discord bot and wanted to make it send a message to a specific "Welcome" channel. Unfortunately, I have been unable to do so. I tried this. const welcomeChannel = bot.channels.get("name", "welcome") welcomeChannel.sendMessage("Welcome\n"+member.user.username); However in this "welcomeChannel is undefined". Edit: I tried using const welcomeChannel = bot.channels.get("id", "18NUMBERIDHERE") welcomeChannel.sendMessage("Welcome\n"+member.user.username); but this is still undefined, strangely You should use the channnel id instead of it's name. How to get the channel id of a

How can I send an embed via my Discord bot, w/python?

99封情书 提交于 2019-11-28 01:55:05
问题 I've been working a new Discord bot. I've learnt a few stuff,and, now, I'd like to make the things a little more custom. I've been trying to make the bot send embeds, instead, of a common message. embed=discord.Embed(title="Tile", description="Desc", color=0x00ff00) embed.add_field(name="Fiel1", value="hi", inline=False) embed.add_field(name="Field2", value="hi2", inline=False) await self.bot.say(embed=embed) When executing this code, I get the error that 'Embed' is not a valid member of the

FORBIDDEN (status code: 403) Can't send messages to this user

核能气质少年 提交于 2019-11-27 08:28:30
问题 I want to make a command that will send a DM to the entire server, but I am getting the following error: Forbidden: FORBIDDEN (status code: 403) Can't send messages to this user What might be causing this? Here is my current code: @bot.command(pass_context=True) async def massdm(ctx, words*): output = " " for word in words: output += word output += "" server = ctx.message.server for member in server.members: await bot.send_message(member, output) 回答1: The user might have blocked your bot or

Discord Bot Can't Get Channel by Name

ぃ、小莉子 提交于 2019-11-27 04:49:59
问题 I have been making a discord bot and wanted to make it send a message to a specific "Welcome" channel. Unfortunately, I have been unable to do so. I tried this. const welcomeChannel = bot.channels.get("name", "welcome") welcomeChannel.sendMessage("Welcome\n"+member.user.username); However in this "welcomeChannel is undefined". Edit: I tried using const welcomeChannel = bot.channels.get("id", "18NUMBERIDHERE") welcomeChannel.sendMessage("Welcome\n"+member.user.username); but this is still

How to install discord.py rewrite?

旧城冷巷雨未停 提交于 2019-11-26 23:28:36
问题 I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? I uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version. 回答1: Try using pip install -U git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py[voice] That should go to the rewrite branch of the discord.py repository and get the egg file to