discord.py-rewrite

discord.py rewrite | Making errors for my commands

岁酱吖の 提交于 2019-12-11 06:35:38
问题 Now that I finished my moderation commands [mostly], I am trying to add errors in. I already made the "please specify a member" error, but I cannot manage to make the bot say "this member does not exist" when an invalid name is input. @client.command(name='kick', brief='Kicks user', aliases=['Kick'], pass_context=True) async def kick(context, member:discord.Member=None): # Errors if not member: await context.send('Please specify a member.') return # Actual Kicking if context.author.guild

How would I make my Python 3.6.1 Discord bot create a new text channel in a server?

陌路散爱 提交于 2019-12-11 06:26:37
问题 I have been reading the documentation. The documentation shows this example: channel = await guild.create_text_channel('cool-channel') I need to figure out what to do with guild so that there is no NameError regarding guild . (Do I have to import guild ? etc.) Documentations: http://discordpy.readthedocs.io/en/rewrite/api.html#discord.Guild.create_text_channel http://discordpy.readthedocs.io/en/rewrite/api.html#guild 回答1: If you are using the rewrite branch, to create a text channel you would

Discord.py rewrite How to DM commands?

我的未来我决定 提交于 2019-12-11 04:58:49
问题 I am trying to have my bot DM the user the help when "-help" is executed. I have tried doing this in my code already but it will not work. async def help(ctx): helpembed = discord.Embed(color=discord.Color.purple()) helpembed.set_author(name="Help") helpembed.add_field(name="-new", value="Creates a new ticket. [Logged]",inline=False) helpembed.add_field(name="-close", value="Closes the ticket.People with the role 'Viewing Team' can close ticets. [Logged]",inline=False) helpembed.add_field

TypeError: Inheritance a class from URL is forbidden

陌路散爱 提交于 2019-12-08 18:53:36
问题 I run into this error when trying to run a bot I made for Discord. This occurred after downloading some modules. Is there any way to fix this? Traceback (most recent call last): File "C:\Users\Jeriel\Desktop\JerryBot\run.py", line 1, in <module> import discord File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\__ init__.py", line 20, in <module> from .client import Client, AppInfo File "C:\Users\Jeriel\AppData\Roaming\Python\Python36\site-packages\discord\cl ient.py",

How to make a bot DM a list of people? (Discord.py) (Rewrite)

断了今生、忘了曾经 提交于 2019-12-08 02:10:14
问题 So this sends a DM to whoever I @mention. @bot.command(pass_context=True) async def pm(ctx, user: discord.User): await user.send('hello') How could I change this to message a list of IDs in let's say a text file, or a list variable containing user IDs? In other words, how can I message multiple people with one command? 回答1: You can use Client.get_user_info to get the User class for a specified id value, if it exists. Here is an example of how this can be done. @bot.command() async def pm(ctx)

How to make a bot DM a list of people? (Discord.py) (Rewrite)

喜欢而已 提交于 2019-12-06 08:05:50
So this sends a DM to whoever I @mention. @bot.command(pass_context=True) async def pm(ctx, user: discord.User): await user.send('hello') How could I change this to message a list of IDs in let's say a text file, or a list variable containing user IDs? In other words, how can I message multiple people with one command? You can use Client.get_user_info to get the User class for a specified id value, if it exists. Here is an example of how this can be done. @bot.command() async def pm(ctx): user_id_list = [1, 2, 3] # Replace this with list of IDs for user_id in user_id_list: user = await bot.get

Reaction Handling in Discord.py Rewrite Commands

老子叫甜甜 提交于 2019-12-02 17:26:43
问题 Is there a way to capture a reaction from a command. I have made a command that deletes a channel but I would like to ask the user if they are sure using reactions. I would like to prevent others from reacting to this message (Only the Context Author should React). So far what I have found is just to use the on_reaction_add() but this can not detect the user who sent the command. I would like to only update the command if the message author is the one who reacted to the message, anyone else,

Print friends-list to console Discord.py

China☆狼群 提交于 2019-12-02 10:17:22
How would I go about printing to console a list of all my friends? I'm hoping to be able to achieve this with the Discord.py library, hopefully someone here knows. I currently get the error: for user in discord.ClientUser.friends: TypeError: 'property' object is not iterable Program: token = "" prefix = "::" import discord import asyncio import codecs import sys import io from discord.ext import commands from discord.ext.commands import Bot print ("waiting") bot = commands.Bot(command_prefix=prefix, self_bot=True) bot.remove_command("help") @bot.event async def on_ready(): print ("Friends")

Discord money bot keeping user ID's in json file. When Bot restarts it creats a new (but same) ID for everyone

只谈情不闲聊 提交于 2019-11-30 09:41:25
问题 When this code runs it works getting the user ID from discord and putting they have 100 money in the json, but once you restart the bot you have to register again and it writes the same user ID in the json file thinking it's a new user when it is not. from discord.ext import commands import discord import json bot = commands.Bot('!') amounts = {} @bot.event async def on_ready(): global amounts try: with open('amounts.json') as f: amounts = json.load(f) except FileNotFoundError: print("Could

How to allow only admins to execute a command

一曲冷凌霜 提交于 2019-11-28 12:01:45
问题 i am writing following command @bot.command(pass_context=True) async def admins_only_command(ctx, *, args): '''do stuff how can i restrict this command to admins only? I tried looking at ctx.author.roles.role and it says @everyone . How can i check if the given user is an admin or not? 回答1: There are two ways: by a whitelist of roles using has_any_role @bot.command(pass_context=True) @commands.has_any_role("Big Cheese", "Medium Cheese") async def admins_only_command(ctx, *, args): '''do stuff