discord.py

Retrieve list of members in channel discord.py rewrite

梦想的初衷 提交于 2021-01-29 13:50:22
问题 Summary I'm really new to discord.py and am trying to figure out how to retrieve a list of people in a discord server channel. I'm working on a command that would randomly separate the channel into two different calls, but I am wondering how I would retrieve the members in a voice channel, create a list of the members, randomly split them, and lastly move the members. My main concern right now is just retrieving a list of members into a list [] format this is what I have so far: async def

How to send a message and collect reactions from it in Discord.py

痴心易碎 提交于 2021-01-29 12:16:50
问题 If a bot was to send a message vote_msg = await ctx.channel.send('Vote ' + '@' + str(member) + ' out of the server? **' + str(out) + '/' + str(of) + '**') await vote_msg.add_reaction('✅') await vote_msg.add_reaction('❎') How could I get the bot to add up the reactions after 30 seconds? 回答1: Use message.reactions : Documentation vote_msg = await ctx.channel.send('Vote ' + '@' + str(member) + ' out of the server? **' + str(out) + '/' + str(of) + '**') await vote_msg.add_reaction('✅') await vote

Is there any way to send a friend request with discord.py?

女生的网名这么多〃 提交于 2021-01-29 11:00:49
问题 I want to add a discord bot to a group chat, and the only way I know how is to add them as a friend first. How do I make a bot send a friend request? I'm pretty sure its possible. 回答1: Bots cannot have friends https://discordapp.com/developers/#bot-vs-user-accounts Bot accounts have a few differences in comparison to normal user accounts, namely: Bots are added to guilds through the OAuth2 API, and cannot accept normal invites. Bots cannot have friends, nor be added to or join Group DMs .

discord.py Error message whenever user dms bot

☆樱花仙子☆ 提交于 2021-01-29 10:36:52
问题 Using the code linked here, I had created a custom prefix for my bot a couple months ago. However, I ran into an issue when I was finally getting into DM responses. Due to the custom prefix, I have been receiving this error and traceback whenever someone dms my bot: Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\bagle\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 802, in get_prefix ret = list(ret) TypeError:

No Command responses using Discord.py Rewrite [duplicate]

不想你离开。 提交于 2021-01-29 10:20:20
问题 This question already has an answer here : Why does on_message stop commands from working? (1 answer) Closed 12 months ago . I have created a discord bot using the code below but when I type .8ball or .ping in the server, I get no response, nor do I get an error message of any kind. However, I do get the expected response of "Hi" when I type "hello" so I know it's connected. It's baffling me as I've checked the syntax 100 times and can't see any errors. import discord import random from

Changing color roles discord

萝らか妹 提交于 2021-01-29 09:42:53
问题 First, I would like to point out that I am a beginner with python. I am trying to write a command that allows the user to change the color of his role via the bot. However, I have encountered many problems that I can not find an answer to. The first problem was that I could not get access to the role of the user calling the command. I decided, however, to skip it and go straight to a specific role. So i made this code: @client.command(pass_context=1) async def changecolor(ctx, NewColor):

Discord.py-rewrite - How to make the BOT self mute or self deaf in a voice channel?

有些话、适合烂在心里 提交于 2021-01-29 08:30:45
问题 I am making a Discord BOT using discord.py-rewrite and am focusing on the Music part of my BOT. I checked the API several times but I do not know how to make my self mute or self deaf on a voice channel (not server mute or server deafen). Anyone please know how I can self mute or self deaf my discord BOT? 回答1: It looks like the API doesn't expose this functionality, but there is a method for doing this in the websocket code @bot.command() async def mute(ctx): voice_client = ctx.guild.voice

my function on_member_join(member) is never called

寵の児 提交于 2021-01-29 08:18:28
问题 i'm doing a discord bot (python 3.8.6). My function on_ready(): is functional, same for my function "say_hello" But i don't know why, discord never detects on_member_join(member) bot = commands.Bot(command_prefix =".", description = "yolooooooooooooooooooooooooooooo") #prints 'logged on' when bot is ready @bot.event async def on_ready(): print('logged on salaud') @bot.event async def on_member_join(member): embed=discord.Embed(title=f"Welcome To Mafia Server, Be carefully or you will die",

Discord.py Detect message in Embed Title or Description

旧时模样 提交于 2021-01-29 08:13:02
问题 I am currently trying to make an 'Anti Selfbot' Bot. I would like to do something good for the Discord Community. Therefore, I have tried to make an on_message event that can detect if an Embed contains 'selfbot', which would cause the message to get deleted and for the user to be banned. I have already begun making my bot. However, I am not sure how to read the content of an Embed. if 'selfbot' in message.content: # do some stuff here So, basically, the only problem I am having at the moment

Making a discord bot that takes a screenshot every 5 minutes and posts it to a specific channel. I'm newer and not really sure what to do next

☆樱花仙子☆ 提交于 2021-01-29 08:08:10
问题 I'm making a discord bot that would take a screenshot of my screen, then post it to discord, and repeat this task every 5 minutes. It seems pretty simple, but I'm pretty new, and have been doing research and not really sure at this point what I've done wrong. import discord import pyautogui import time import datetime class MyClient(discord.Client): async def on_ready(self): print('Logged on as', self.user) if datetime.datetime.now().minute % 5 == 0: myScreenshot = pyautogui.screenshot()