discord.py-rewrite

How would I get every text and voice channel and denying @ everyone to read it, and then allowing another role to read and send?

喜欢而已 提交于 2020-02-06 08:37:28
问题 I wondered how when the bot is added to a guild, I can make it get every text and voice channel and then deny @ everyone access to read it, but then allow another role called 'Verified' to read it? I am using the rewrite version of Discord.py EDIT: I found how to change the permissions using await message.channel.set_permissions(message.author, read_messages=True, send_messages=False) But I still don't know how to apply this on every channel 回答1: Posting this here for others, even though you

How to make my discord.py rewrite bot send a Private Message to the message author

▼魔方 西西 提交于 2020-01-30 11:57:07
问题 I have made a Discord bot for a game's Discord server. I'm using the discord.py rewrite version and I want to send a private message to the author of the message. I've tried other codes on the internet which includes some "@bot" code, but it always comes up with the error "Name 'bot' is not defined" and if I try send_message it says "Client object has no attribute 'send_message'" My code: #I've tried this... @bot.command(pass_context=True) async def poke(ctx, message): await client.send

How to make my discord.py rewrite bot send a Private Message to the message author

会有一股神秘感。 提交于 2020-01-30 11:56:10
问题 I have made a Discord bot for a game's Discord server. I'm using the discord.py rewrite version and I want to send a private message to the author of the message. I've tried other codes on the internet which includes some "@bot" code, but it always comes up with the error "Name 'bot' is not defined" and if I try send_message it says "Client object has no attribute 'send_message'" My code: #I've tried this... @bot.command(pass_context=True) async def poke(ctx, message): await client.send

Is the a way to use prefix AND ping for commands?

泪湿孤枕 提交于 2020-01-30 11:39:10
问题 I've decided to create a much more helpful bot, and I would like to allow the commands to be activated in two ways: x. which is the default prefix and @xubot , aka pinging the bot. My commands are set out like this: # sidenote: this is not an actual command ;) pref = 'x.' client = Bot(command_prefix=pref) @client.command(name="example", pass_ctx=True) async def example(ctx, type=""): # the "type" parameter is used so i can check if it is "help" and display an embed await ctx.send("Test!")

Is there a way to include spaces in my argument?

Deadly 提交于 2020-01-30 10:40:48
问题 In my discord bot, I have 2 commands do give and create roles. They work perfectly fine, but if the role name includes a space, I have an issue. It counts the second word toward the second argument, making the command produce an error. # Giverole @client.command(name='giverole', aliases=['gr'], brief='Assgins role to a user', pass_ctx=True) async def giverole(ctx, rname, *, member: discord.Member): role = get(member.guild.roles, name=rname) await member.add_roles(role) await ctx.send(f'Role

Is there a way to include spaces in my argument?

大憨熊 提交于 2020-01-30 10:38:49
问题 In my discord bot, I have 2 commands do give and create roles. They work perfectly fine, but if the role name includes a space, I have an issue. It counts the second word toward the second argument, making the command produce an error. # Giverole @client.command(name='giverole', aliases=['gr'], brief='Assgins role to a user', pass_ctx=True) async def giverole(ctx, rname, *, member: discord.Member): role = get(member.guild.roles, name=rname) await member.add_roles(role) await ctx.send(f'Role

How can I run an async function using the schedule library?

大憨熊 提交于 2020-01-21 09:10:15
问题 I'm writing a discord bot using discord.py rewrite, and I want to run a function every day at a certain time. I'm not experienced with async functions at all and I can't figure out how to run one without using "await." This is only a piece of my code which is why some things may not be defined. async def send_channel(): try: await active_channel.send('daily text here') except Exception: active_channel_id = None active_channel = None async def timer(): while True: schedule.run_pending() await

Remove 'command not found' error discord.py

北战南征 提交于 2020-01-13 20:33:08
问题 In a discord.py rewrite bot, if someone types the bots prefix and then any text after it, if the text is not found as a command you will get Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "sd" is not found Is there anyway to stop the bot from logging this? 回答1: Write an on_command_error error handler that checks if the error is an instance of CommandNotFound , and ignores it if it is from discord.ext.commands import CommandNotFound @bot.event async

Message object has no attribute 'server'

浪尽此生 提交于 2020-01-11 10:29:13
问题 Using the following lines of code: @bot.command() async def report(ctx): author = ctx.message.author server = ctx.message.server wait ctx.send("Author: " + str(author) + "\nServer: " + str(server)) I get the error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server' It's not a problem with importing the libraries because I can change the line to ctx.message.channel and get the channel name. The author collects

Discord.py Self Bot using rewrite

*爱你&永不变心* 提交于 2020-01-06 05:44:07
问题 Hello im trying to make a selfbot using discord.py rewrite for educational testing. Im stuck currently with making a simple command which responds to a command. I want my selfbot to say "oof" when I type and send ">>>test" here is my code: import asyncio import discord from discord.ext import commands bot = commands.Bot(command_prefix=(">>>"), self_bot=True) @bot.event async def on_ready(): print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)") @bot.command() async def test(self, ctx): await self