#discord-bots
1 messages · Page 597 of 1
!pypi disnake
Because you loop through all the members of the guild (aka server)
And there's not only the author as member of the guild
Hello, I am trying to make a discord bot to play music. This is the code I have for the play command
@client.command(name='play', help='This command plays music')
async def play(ctx,url):
if not ctx.message.author.voice:
await ctx.send('You must be in a voice channel to play music')
return
else:
channel = ctx.message.author.voice.channel
await channel.connect()
server = ctx.message.guild
voice_channel = server.voice_client
query = await client.wait_for("message")
query2 = query.replace(" ","+")
url = "https://www.youtube.com/results?search_query={}".format(query2)
html = urllib.request.urlopen(url)
video_ids = re.findall(r"watch\?v=(\S{11})",html.read().decode())
full_url = "https://www.youtube.com/watch?v=" + video_ids[0]
async with ctx.typing():
player = await YTDLSource.from_url(full_url, loop=client.loop)
voice_channel.play(player, after=lambda e: print('Player error %s' %e) if e else None)
await ctx.send(f'Now Playing: {player.title}')
When I use the play command in discord the bot doesn't do anything
oh really? that's what it should do
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
Wdym dpy is still usable but not maintained and disnake is the best option,has the same syntax
Hello I am pretty new to discord.py have been working with for a about one month I have built a cryptocurrency bot but I still feel like I am lacking fluency with the library . I am looking for bot ideas do you have any to suggest ?
Rank system, rank shop,polls and giveaways
Hey so when I try to make my bot token a secret using
client.login(process.env.token)
It says
Traceback (most recent call last);
Wdym a secret are you using replit?
Yeah I’m on chromebook so can’t use vsc
process.env.token? This isn't javascript
Rank shop ??? What is it
I think so never seen it before
They use process.env in javascript
Ranks like levels kinda stuff
Idk i dont use js lmao
Idk that’s what my friend told me to use
Are you sure your friend is using discord.py???
Cause from what they told you seems to me like they are using javascript
And not discord.js
He said he’s using js but it’s the same command Idfk I’m new to this lol
It isn't the same thing
Not same syntax
Doesnt seem like your friend understands python
Bro?
<@&831776746206265384> someone sent a nazi logo picture in the chat but got deleted so pls stay in the look out
!d os.getenv
os.getenv(key, default=None)```
Return the value of the environment variable *key* if it exists, or *default* if it doesn’t. *key*, *default* and the result are str.
On Unix, keys and values are decoded with [`sys.getfilesystemencoding()`](https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding "sys.getfilesystemencoding") and `'surrogateescape'` error handler. Use [`os.getenvb()`](https://docs.python.org/3/library/os.html#os.getenvb "os.getenvb") if you would like to use a different encoding.
[Availability](https://docs.python.org/3/library/intro.html#availability): most flavors of Unix, Windows.
^
So
os.env.get(token)
Irrc client.run(os.env.get(token))
Idk i dont use replit
Ah ok I’ll try it thanks 😊
that's another way to do it yeah
^
Thx for the correction ig
Now it’s saying “os” is not defined I hate this lol
import it
import os
^
Bruh I hate this sm
It now says token is not defined but it’s written the same in the secret repl hates me
Pic is sending
Your doing token
Not "token"
You need to pass the name of your environment variable
Finally
Thanks bro
Yeah but eventually it will end, api will keep upgrading and eventually deprecate the current version. I'll check out disnake thanks
Yeah and yw
If I wanted to get a list of all the commands that are available in my bot how can I do that?
If your command prefix is ! do !help
not in the discord server I wanna get the list in my python script
idk
ok thnx anyway
You want a list of all the commands in a script and add it to a list?
I wanna map it with another list
Working with polls and voting now.
I'm using embeds and would like to implement reaction voting.
Two questions: Is there already a method for polls with discord.py?
If not, how can I check when a user has "voted" (clicked on a reaction)?
I know there's an on_reaction_add() event handler but I'm not sure how to implement this in a way that it will only be invoked when a reaction is added to one of the poll embeds, not any other message
you can use i think client.commands its a list of all the commands in your bot
!d discord.ext.commands.Bot.commands
property commands: Set[discord.ext.commands.core.Command[discord.ext.commands.core.CogT, Any, Any]]```
A unique set of commands without aliases that are registered.
ok thnx
How would I go about making a command that changes the activity of the bot? Naturally I’d want it locked to me but I could do that part
I think you ment a task
Nah I want to change the activity with a command at any moment
you can do
@client.command()
async def change_activity(ctx, activity):
await client.change_presence(activity=discord.Game(name=str(activity)))
but everyone can use this command you may need to check if the author is the owner of the bot
i think it could work
Alr thank you
np
Or just use the owner check decorator thing
bot.run(os.getenv("token"))
@client.command()
async def change_activity(ctx, activity):
if ctx.author.id == '591047383044063244':
await client.change_presence(activity=discord.Game(name=str(activity)))
else:
await ctx.send('This command is restricted for Wind!')
This is sending the else statement when I try
Yeah but thats if the person has admin perms but if its a public bot and only the bot owner can do it just do is_owner or there was something like the in the docs dont quite remember
Your comparing id attribute of author which is an int to a str
It will always be false
You need to remove the single quotes from the id you are comparing it to
Oh I did that and it gave an error but it just wasnt loading, thank you
If you do it a bunch of times you will get ratelimited btw
Dont know how much requests but its in the docs
Figured as much, I dont plan to spam it 80 thousand times tho
Prob just 1-2 times every now and then
Its a gateway command so
You can do 120 change presence commands in 60 seconds at a time without getting ratelimited
After that you will be automatically disconnected
Oh good, so I dont have to worry
Wdym by gateway?
How do you even remember that😭
change_presence is a payload directly sent to the gateway
Not an endpoint on the API
I see
I remember it because I'm writing my own discord API wrapper
I remember making the ratelimiter for the websocket
Oh wow nice
just curious whats your goal exactly?
Goal for what
Like for the project ig like what are you trying to achieve?
Just curious btw dont mean it in a bad way
A cleanly written wrapper and one with 100% coverage other than user endpoints
As well as utility focused
how do i use find_one_and_delete in mongodb?
so its an unblacklist command and i wanna erase the user's id along with the blacklist reason from the db (its in one document tho)
Oh nice good luck on the project!
Thanks, we already have 100% coverage on rest Iirc
Oh wow best of luck with the project hope it goes big with all the effort you guys put in to it!
not going so well morale wise rn
I decided last night to switch docstring style to rST
😭
So I literally have to redoc the whole library
That's what I'm doing right now actually, spent the whole day going through 5k lines of code redoccing
Damn wish i could help you but im intermediate lmao
Best of luck 😭
I have 0 idea about it
^
Isn't that what I said?
You gaved a option that didnt specified "owner" exactly
Huh
I said owner check decorator which totally means the is_owner check which is a decorator
Alr🤷♂️
Yes i know it is
@client.command(aliases=['8ball'])
async def _8ball(ctx,*, question):
responses = ['"it is certain.",
"It is decidedly so.",
"Without a doubt.",
"Yes - definitely.",
"You may rely on it.",
"As I see it, yes.",
"Most likely.",
"Outlook good.",
"Yes.",
"Signs point to yes.",
"Reply hazy, try again.",
"Ask again later.",
"Better not tell you now.",
"Cannot predict now.",
"Concentrate and ask again.",
"Don't count on it.",
"My reply is no.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
']
Pic loading of error
do you not see the error?
!e py print('"why is there a single apostrophe before this string")
@heavy folio :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print('"why is there a single apostrophe before this string")
003 | ^
004 | SyntaxError: unterminated string literal (detected at line 1)
@regal shell read this
in discord.TextChannel.delete_messages is the messages arg just a list[int] or a list of message objects?
message objects they should be
can i make them custom objects with attribute "id" set to a snowflake?
because it would be very ineficiant if i had to fetch all the messages
!e
print('"why is there a single apostrophe before this string"')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
"why is there a single apostrophe before this string"
!d discord.Object
class discord.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the object’s hash.
thanks
yea sure
oh skelmis already answered it
error.missing_perms must be the thing
you would have to add a py @commands.bot_has_permissions() check in the command tho
how would i add square root to this calculator command? would it be the same as just doing another elif or- (i already imported math)
https://mystb.in/RecognisedInsertionGovernance.csharp
- it's
client.command(), notclient.command, client.command()needs to decorate an actual coroutine- your
client.run(...)is indented incorrectly, if done correctly, it should be at the top-level indent
no i had it correct its because i had a random @ client.command in there
the command wasnt finished so it was trying to use the token as the command im guessing
What are things needed to delete a message sent by webhook
hey
i have a doubt
while making discord bots
this is my commands
import discord
from discord.ext import commands
import music
cogs = [music]
client = commands.Bot(command_prefix = '!')
@commands.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.send(f"{member} was kicked!")
@commands.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f"{member} was banned!")
@commands.command()
async def ping(ctx):
await ctx.send('Pong!')
@commands.command()
async def beg(ctx):
await ctx.send("Oh, Your are begger atleast get 10,000$ and support #TeamSeas , from MrBeast")
@commands.command()
async def spank(ctx):
await ctx.send("Spanking [TPG] Gurami#3388!")
@commands.command()
async def welcome(ctx):
await ctx.send("Welcome Mr.Nightmare#0361")
@commands.command()
async def minecraft(ctx):
await ctx.send("I like mincraft alot but don't have sadly!")
@commands.command()
async def wth(ctx):
await ctx.send("What da fak is wrong with you guys!!!!!!!!")
@commands.command()
async def amogus(ctx):
await ctx.send("u look like ssssussy cat")
@commands.command()
async def die(ctx):
await ctx.send("why do u want to die")
@commands.command()
async def annoy(ctx):
await ctx.send("why do you like pinging!")
@commands.command()
async def rules(ctx):
await ctx.send("1.Always have fun 2.ping everyone 3. NO spamming 😦 4.Be friendly :)")
@commands.command()
async def plsbeg(ctx):
await ctx.send("Oh you poor little beggar, take $1,602 and a Laptop")
@commands.command()
async def inv(ctx):
await ctx.send("U have 1602$ and a laptop")
@commands.command()
async def kill(ctx):
await ctx.send("Are you out of your dumb mind!")
@commands.command()
async def rickrole(ctx):
await ctx.send("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
client.run("TOKEN")
The official video for “Never Gonna Give You Up” by Rick Astley
“Never Gonna Give You Up” was a global smash on its release in July 1987, topping the charts in 25 countries including Rick’s native UK and the US Billboard Hot 100. It also won the Brit Award for Best single in 1988. Stock Aitken and Waterman wrote and produced the track which w...
What
U should probably lock ban and kick to members already with those perms
You should rename client to bot since it is not just a client but rather a bot, and you need to do @bot.command() not @commands.command()
And I'm assuming it's running? Otherwise you need to add bot.run("and put your bot's token here") to the bottom of your code
He got that but client.run
what exactly is the issue, aside from the fixes others have suggested?
Hi guys, how would I make a command where its also listening for another members id or @mention,
e.g. !stats @ other user
add a member argument to your command func
Yeah I have, but just a little confused
thx man i appreciate
and i am using replit for some reason
i use to use visual
import discord
from discord.ext import commands
import youtube_dl
class music(command.Cog):
def init(self, client):
self.client = client
@commands.command()
async def join(self,ctx):
if ctx.author.voice is None:
await ctx.send("You are not in the voice channel!")
else:
await ctx.voice_client.move_to(voice_channel)
@commands.command()
async def disconnect(self,ctx):
await ctx.voice_client.dsconnect()
@commands.command()
async def play(self,ctx,url):
ctx.voice_client.stop()
FFMPEG_OTIONS = {'before_options: '-reconnect i -reconnect_streamed 1
-reconnect_delay_max 5', 'options': ':vn'}
YDL_OPTIONS = {'format':"bestaudio"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url, **FFMPEG_OPTIONS)
vc.play[source]
@commands.command()
async def pause(self,ctx):
await ctx.voice_client.pause()
await ctx.send("Paused")
@commands.command()
async def resume(self,url):
await ctx.voice_client.resume()
await ctx.send("Resume")
def setup(client):
client.add_cog(music(client))
see
like
i need to download moules
modules*
can someone suggest me>?
i have did it
but i dont want to leak token
Using yt for a music bot is against yt TOS btw
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
And you probably want to use on kick and ban command ```py
@commands.has_permissions(permission = True)
Code and traceback?
no
i use visual
and whas the
command
client.command()
or
bot.command()
or
commands.command()
Depends on your commands.bot.Bot var tbh
Not a command its a decorator
yo
@hazy agate i think i have a fix for the ban
wdym
@hazy agate
client.command()if you named yourcommands.Botinstanceclient(bad naming practice, should not be doing this)bot.command()if you named yourcommands.Botinstancebot(good naming practice, should be doing this)commands.command()if your command is within acommands.Cogsubclassed class, or you are usingbot.add_command()to manually register a command
what
like i dont know how many modules i need to download
You were asking about the difference between client.command(), bot.command() and commands.command() right?
Making a music bot violates YouTube's Terms of Service, and as such we can't really help with that here
idcabt yt cuz yt has taken down rythm and groovy
we do
Right, rhythm and groovy were taken down as they were found in violation of their terms of service. We can't really help you make a bot that violates their TOS
^
looks as if someone has already linked it
You cant really expect them (not us bc idk a single thing abt music bots) to help with a bot that can potentially violate ToS 
We won't stop you from making a music bot (I personally discourage it), but you will have to find out how to do so by yourself
small hint would be github
Not potentially, it does violate their ToS
👀
Partially
wut abt lavalink?
Hey why isnt this working. trying to make it so people can only send the commands in certain channels.
talk_channels = [892691480228020235]
@bot.command(pass_context=True, name="leave", aliases=["l"], description="Remove yourself from the queue")
async def leave(ctx):
if ctx.channel.id in talk_channels:
But the bot just doesnt hear the command at all even from that channel given
join my testserver
I dont understand, it should be working
stop advertising
Bro read the rules
Doesnt matter your asking people to join your server
and 1 for testing
If you asked something along the lines of "How can I use Lavalink to play an mp3 file present on my machine through my bot on Discord", we would have no problem explaining that. But if you ask us how to play a YouTube video through it, we can't really help with that
you may have left something out, there's nothing after the if statement though
There is I just didnt include it in the code
I know for a fact that the code after it works
bro
also this is more suited task for on_message or a global check, so that you can use all commands in certain channels without doing the if statement in every command
@hazy agate
1.please stop asking for help with projects that break tos of some platforms as YouTube or discord
2.please stop advertising
3.read the rules
You can, with JDA, but this is the Python server, not the Java server
hmm, how would I do that?
when a user types the command, how do i make it delete after they sent it?
@client.command()
async def verify(ctx):
if ctx.channel.id == 909671265864933406:
fullaccessrole = get(ctx.guild.roles, id=909670961115201537)
await ctx.author.add_roles(fullaccessrole)
Node.JS is not Java, it is Javascript. There is a big difference.
srysyr
If you wish to make a music bot using Java, look into JDA
If you wish to make a music bot using Javascript, look into Discord.JS
call the delete() coroutine of a discord.Message object, which you can obtain through ctx.message
so irritated
await ctx.delete()
We won't help you make a music bot here. Period.
oh okay ty
Np
no, it's await ctx.message.delete()
^ @slate swan
Havent used the commmand in a whole
That's alright, I can see where you're coming from as the context object has some methods typically associated with a message object
Yeah
ty 👍
You'll have to be more clear than that
Provide code and full tracebacks for us to debug your code.
thena async def blank(ctx):
I suggest learning more about python and dpy
await ctx.send("blamd")
Can you please send the full traceback?
but doesn't work for mee
Saying "it is telling wrong" helps nobody understand what's wrong
We need to be able to understand whats wrong in order to fix it
i will share screen
sending ss is easier
I'd prefer not, can you copy & paste the full traceback here?
?
screen shot
Either send a screenshot or copy and paste it
copy the traceback in ur terminal
no
i dont understand your words
can u dm
or
Copy the full error, and paste it here
ok
i dont like to dm
Or take a picture of it, whichever you find easiest
Your making stuff more complicated that it needs to be
Would I delete the message if its not in that channel or how would I ignore it with an on_message event
You want to delete the message that invoked the command, correct?
Right, no need to dm or screenshare, just send a picture of the error
No I'm just trying to make the commands only work in specific channels
check ctx.channel
Right, you can implement a global check (preferable) or use on_message (works but is kind of meh)
would this be right? im trying to make it delete every message a user sends in that channel
@client.command()
async def verify(ctx):
if ctx.channel.id == 909671265864933406:
fullaccessrole = get(ctx.guild.roles, id=909670961115201537)
await ctx.author.add_roles(fullaccessrole)
await ctx.message.delete()```
bro try it and see
an if statement
A global check is a check in all commands correct?
ctx.message refers to the message that invoked the command, so it would delete the message that triggered the command, if that's what you want.
Correct.
I have but I was suggested otherwise
Thank you
Would you mind telling me how id do a global check?
Ur choice but my way you could create a list and put all the IDs in there and then u could check where the command was invoked
code:
import discord
from discord.client import Client
from discord.ext import client
def new_func():
client = Client.Bot(command_prefix = "!")
thats what Ive already done
client.Bot is not a thing
@boreal ravine
whats the issue then
Its not working
@bot.check
def check_commands(ctx):
return ctx.command.qualified_name in allowed_commands
From the raw docs
You dont have to make a function for a var????and no need for so much imports
it isnt async?
apparently not
🤔
Though the documentation specifies it can be either
Ah ok then
This function can either be a regular function or a coroutine.
I assume calculating a boolean value would be sub-millisecond, so making it asynchronous is like bringing a gun to a knife fight.
@hazy agate i recommend you learn some of these things:
https://pythondiscord.com/resources
https://vcokltfre.dev/
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Too op
OHH wait not really, basically what im trying to do is make the bot delete every message including the command, but if they type the command correctly it gives them access to the rest of the server
Sort of like a verify command?
yes
Oh I see, then you can just delete all the messages in that channel after the user invokes the commmand
so If I do
@bot.check
def check_commands(ctx):
return ctx.command.channel.id in allowed_channels
``` would that check if all commands are in the right channels?
given allowed_channels is a list of integer IDs, yes
gotcha
Is it possible to count the amount of roles someone has and use it?
Though I'd probably rename the function to something more fitting
len(member.roles)
so uh await message.delete()..?
So if I were to do x = len(member.roles) I could use x as the count?
that would delete only the message that triggered the command, you'd be looking for something like channel.purge() to delete all the messages in that channel
That is correct.
Thank you
My pleasure
😂
He could do a purge with a limit so if the bot always will send a amount of messages and the user as well you get the total of all the messages that will be sent when the command is invoked and you just delete the amount

I'm losing hope this still isnt working
What do you mean by "it isn't working"
We'd need to see your code, what you expect, it's current behaviour, full traceback if applicable
a chance that something is blocking it from running
Sorry for basic question again but would msg.channel.id work for getting ID of the channel the message was sent in? Assuming msg = message.content
Theoretically, yes, but if the bot clears the messages in the channel every time the command is run, then it shouldn't have any messages there in the first place.
No, assuming msg = message
message.channel.id would do the job
thank you
Good point🤷♂️
Purging some arbitrary small number such as 10 should suffice
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Is there a traceback with that?
there was no errors
Just a side note, you don't have to pass in the pass_context and name kwargs, if the name and the name of the function are the same
Then what's the problem?
that the bot isnt picking up when I type a command in the allowed_channels
Which command is it not picking up? All of them or just some?
Perhaps because it's ctx.command.channel.id rather than ctx.message.channel.id
You don't have to wait for it to go offline
It takes only 1 second. It's Discord API issue which shows the bot online
oh what
Try running commands after u stop the code
Just turn it off and back on server-side, changes take effect
It won't work haha
^
I've had it glitch out where my bot was online overnight, even though my server was completely unplugged haha
Haha
Its me again. So I wanted to create a command that bans someone if they type in a certain channel, then instantly unbans them, like Dyno's ?softban.. just automated.
if message.channel.id == 909685766244945921:
zxc = message.author.id
await message.author.ban(reason = 'You typed in the kick channel!')
await message.guild.unban(zxc)
Would something like this work?
Sure
BTW
!d discord.on_typing is also there in case u wanna ban as soon as the person starts typing
discord.on_typing(channel, user, when)```
Called when someone begins typing a message.
The `channel` parameter can be a [`abc.Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") instance. Which could either be [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel"), [`GroupChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.GroupChannel "discord.GroupChannel"), or [`DMChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.DMChannel "discord.DMChannel").
If the `channel` is a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") then the `user` parameter is a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"), otherwise it is a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
This requires [`Intents.typing`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.typing "discord.Intents.typing") to be enabled.
Damn nah I dont wanna be that strict, just as long as that works
It should work
It would work
😭
great, now my mongodb "certificate verify failed"
U gotta do message.guild.unban(discord.Object(zxc))
Won't work with ID, u gotta convert to a discord Object
May i ask what is a snowflake my good sir?
Yea
I see thank you 
Alright so now, if I wanted it to only kick people with no roles..
if message.channel.id == 909685766244945921:
plop = len(message.author.roles)
if plop == 0:
zxc = message.author.id
await message.author.ban(reason = 'You typed in the kick channel!')
await message.guild.unban(discord.Object(zxc))
would this do?
Discord takes some things from twitter, for example the emojis are from twitter, so are the IDs
Makes sense 😭
you could probably condense that and remove the plop variable
same with the zxc variable
So..
if message.channel.id == 909685766244945921:
if len(message.author.roles) == 0:
zxc = message.author.id
await message.author.ban(reason = 'You typed in the kick channel!')
await message.guild.unban(discord.Object(zxc))
Then how would I get rid of zxc
await message.guild.unban(discord.Object(message.author.id))
just substitute message.author.id into where zxc is within the discord.Object()
For me, the rule of thumb is to never make variables that are only used once
o yeah I was thinking of something but it actually made sense lol. I thought that as soon as you ban the bot would throw the ID out 😭 but yeah it makes sense now, thank you
PEP 8 of course
Nah
IIRC it was 80 columns per line? Give or take 10
Yea it's 80
I have manually set it to 120 cz I had 10 errors in my file all due to line lengths and, well, all those lines had list comps 😐
The bot takes a snowflake for unbanning rather than a member or user object, as if the member is banned, the bot can't actually "see" the user, so it takes an ID instead
Makes sense, so the code isnt working 
Not always haha. What if the user has more than one mutual guilds?
Any error?
Nah
plz help whats the problem here?
That's fair
Just isnt working 
U tryna ban yourself? You can't ban the owner
Regen your token
Try removing the blank line
ok

ok
Token 

Question if a user gets ban in a guild by a bot if the user shares a guild which the bot is in will the bot ban him in all or just the guild the command got invoked?
Just the guild
Id asume just the guild, but Im not sure
I see thank you
You have 2 methods of banning a member:
- Using a member object (
member.ban()) - Using a guild object (
guild.ban(member))
Both methods tie to a singular guild, so no matter which method you use it will only ban within the guild
Now time to shamelessly change topics.. any idea why my bot is ignoring the on message now?
Ok thanks
And a third method
How is it ignoring the on_message? Have you tried putting a print statement at the top of the on_message?
Well its not ignoring the on_message so much as its ignoring the
if message.channel.id == 909685766244945921:
if len(message.author.roles) == 0:
await message.author.ban(reason = 'You typed in the kick channel!')
await message.guild.unban(discord.Object(message.author.id))
bro i really want to make music bot
Try a print in both the top-level if and the nested if
Alright
It'll help diagnose which if statement is not working
As the others and I have said before, we won't help with music bots. Period.
We can help for music bots
Ok its ignoring the second part
Given it doesn't use YouTube videos
Not all music bots are directly streaming from YouTube or other services
Sorry, should've been more clear about that haha
But to come back to this, there's also
bot.http.ban(user_id, guild_id, days_delete)
That reminds me
the @.everyone role counts as a role
then help me make it
o
Check if they have 1 role, rather than 0
So, thats why 
This takes the guild_id, which also ties to a singular guild, so in all 3 situations the user can only be banned from one singular guild
That's progress
how do i use find_one_and_delete in mongodb?
so its an unblacklist command and i wanna erase the user's id along with the blacklist reason from the db (its in one document tho)
Ig the bot needs permission to ban people 
Who would've guessed
Yes, but you've said
You have 2 methods of banning a member
which is not really accurate
what is this!?
Yeah, more like 2 commonly used methods hehe
Can be used to hackban
Sheeeesh
You have intents right?
Look, if I don't answer it means I've never done a music bot, so please stop. I just say we can help for music bots not playing music from YouTube, that's it.
Wym?
ok not from yt
Like does your bot have intents
but can i make from lavalink?
Also 2fa is required for mod actions on this server so is there a way to get around that?
Lavalink streams from YouTube
once again ^^^^^^^^^^
Not sure if lavalink allows playing music from mp3
Not for bots

Bots should be exempt from that
We did already
You already got told
Remove your token, get rid of the space
Remove the line
I did
Clearly not
read the error
ok
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 50, in on_message
await message.author.ban(reason = 'You typed in the kick channel!')
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/member.py", line 554, in ban
await self.guild.ban(self, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/guild.py", line 2026, in ban
await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 60003): Two factor is required for this operation
Its yelling at me
trying agaon
Hmm?
That's uh quite strange

!ban @hazy agate
means the server doesnt have 2fa enabled
Perhaps you need 2FA enabled on your account?
no
Remove this line, and hide your token next time. Now delete your screenshot and regenerate a new token
I have 2fa enabled on my account, do I need it for the account the bot was made on?
ok
Bots can't really use 2FA
That would explain it
Understandable
^^^^^^^
You may have better luck asking in #databases
Or take a look at the library documentation you're using
Awesome!
@slate swan bro same error again I regenerated the token
see
You didn't created the client variable
And you're using @commands.command which is for cogs
So only use @client.command and create the client variable
Does another command work?
yes ping command works
Well, indent the ping command correctly first
u dm me once
😭
@slate swan what to do?
Indent it correctly
ok
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
And this white bullet shows you haven't saved the file
Suggest turning on auto-save
Or be like me and spam ctrl+s every second

Im always saving i never trust it its a fear😭
I get paranoid
same im now used to command+s (ctrl+s for u windows ppl)
I do it manually cause im weird
... WHAT THE FU-

if you'd rather have no syntax highliting over code completion, WHAT THE FU-
🤷♂️ 
My favorite shortcuts are Ctrl+S and Ctrl+Alt+L
We all know you love ctrl c and ctrl v😉
Indeed
Who doesnt 🤷♂️ 
But unlike others, when I copy some code because mine triggers me, I fix it and make so that it works in my project
Others just copy paste and then they're like "Why doesn't it work?"
Yeah
Same
I understand all code i copy i just dont like doing long commands so i just copy them and fix them for my code 🤷♂️

Me rn:
Back to topic please
@slate swan sorry for the ping but what's the difference between a corountine and a function and are they the same thing?
They do the same, but are used in different context
Basically in short words, a coroutine runs in background
So doesn't stop your entire program from running
Ah i see
If you call 2 functions one after the other, the second function will only be executed when the first is finished
So its a async function?
If you turn the first function in a coroutine, it will run in background and the second can run simultaneously
Basically yeah, just add async
Then there are different usages
Thank you for the explanation i just gotta get my terminology 
You can do
asyncio.run(main())
considering main is a coroutine
I see🤔
And like
Yeah ive done it before but never knew the real explanation or a good one
await echo("world")
echo("Hello")
gives some output like:
Hello
world
world
Hello
world
Hello
Hello
world
world
Hello
echo just prints 5 times the string from the argument
And as you can see both functions are running simultaneously
Without a coroutine it would just be 5 times world and 5 times Hello
Why 5 times?
That's what the function does
Prints 5 times the string
Hmmmm
Yeah lazy to copy the function code
Thank you bro 👍 
Wait
Yeah nevermind
Should be both 2 different functions
Lmao
Yeah I don't understand Python anymore
😭
You can only use await if it has async keyword
That's why I hate Python
Can't turn a function to a coroutine whenever you want
Yeah
😭
Sucks ig
That's why I don't do projects that needs to be asynchronous with Python


Like
async def echo():
print("coro")
asyncio.run(echo())
echo()
This is not possible
Second call will return error
It won't return error
it will
A RuntimeWarning
Its 3:30am i cant anymore😭
Which won't execute the code in the function
Ah right, mb
It will return a coro object no?
It'll just say it wasn't awaited
Oh that was- ah never mind
Ah
It's just pain
That's why I hate Python's asynchronous coding
Sleep 
No need

so im trying to use a command in dms but i keep getting this error discord.ext.commands.errors.NoPrivateMessage: This command cannot be used in private messages.
You have a check on the command that prevents you from executing the command in private messages
You probably have something like @commands.guild_only()
@bot.command()
@commands.is_owner()
#permissions
async def role(ctx, user : discord.Member, *, role : discord.Role):
if role in user.roles:
await user.remove_roles(role) already has
await ctx.send(f"Removed {role} from {user.mention}")
else:
await user.add_roles(role)
await ctx.send(f"Added {role} to {user.mention}")
DMs don't have "roles"
You need to get a member object from the guild, not a user object, and add roles to that
how would i do that
What’s the simplest way to give your bot a custom prefix function
Get guild
Guild.get_member
Member.add_role
Iirc. I might be wrong
Custom prefix function as in?
Like a command to change the prefix?
yeah
async def on_reaction_add(self, user, reaction):
print("Normal Reaction")
hey guys. for some reason, this event is never called. 'on_raw_reaction_add' does though. Does anyone know why? thanks :))
The message is not in the last 50 message cache or is too old
So the bot forgets the message but on_raw_reaction doesn't depend on age of message
ahhh ok
Just read the docs on those, pretty good stuff
lemme test somethin
yea i did i just didnt understand haha
Well
How are you storing prefixes for guilds and using them
I haven't really worked with multiple server bots before, so I just:
On_command: change prefix
Write new prefix to db
Bot.prefix=new prefix
And while initiating I select it from the db
That is one way, I'm pretty sure there are better.
mongodb
is it possible to use an image from my local pc instead of a URL in an embed?
Not 50 but okay
yes
ah thanks , i figured out
:D
now new problem
How to attach an image from a url without an embed?
u mean like sending a normal image?
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
!d discord.TextChannel.send then send it using the file kwarg
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
It isnt an embed
I dont think u can send images without using discord.File
okay i figured out
await channel.send("URL") ```
Works
🥲
Bruh ok
hey
What
how can i make a tic tac toe bot
Make it ez
@hazy agate you'd be better off finding a prerecorded help video vs a chat app
If you need help you can ask here
ok
How to get the permission integer of bot in a guild?
wat
How to get permission integer
if bot has admin perms, it would return 8
Hey can someone help me out with a custom prefix command.
Im using mongo db
I originally tried:
def get_prefix(bot, message):
options = settings.find_one({"guild_id": message.guild.id})
prefixes = options["prefix"]
return prefixes
bot = commands.Bot(command_prefix=get_prefix)
@bot.event
async def on_guild_join(guild):
guild = settings.find_one({"guild_id": guild.id})
if guild is None:
newguild = {"guild_id": guild.id, "prefix": "!", "game_id": 1, "qsize": 6}
settings.insert_one(newguild)
@bot.command(pass_context=True, name="prefix", description="Change the bot prefix")
async def prefix(ctx, prefix):
if ctx.channel.id in allowed_channels:
options = settings.find_one({"guild_id": ctx.guild.id})
settings.update_one({"guild_id": ctx.guild.id}, { "$set": { 'prefix': prefix } })
embed = discord.Embed(description=f"The prefix has been update to {prefix}", color=0xE74C3C)
embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
await ctx.channel.send(embed=embed)
!d discord.Permissions.value
The raw value. This value is a bit array field of a 53-bit integer representing the currently available permissions. You should query permissions via the properties rather than using this raw value.
and you would use something like , guild.me.guild_permissions to get the discord.Permissiom object
What problem do you face
Idk if I am doing anything right tbh
I just tried something
Is settings variable your mongo client?
settings is my collection
cluster = MongoClient(
"mongodb+srv://~")
database = cluster["6mans"]
pstats = database["stats"]
settings = database["settings"]
File "D:\6Mans\Main\mainwithdict.py", line 15, in get_prefix
prefixes = options["prefix"]
TypeError: 'NoneType' object is not subscriptable
so how would I fix that
insert something
@boreal ravine I did that on guild join
o wait
👀
fixed
ngl that code looks ugly asf please use some code fornatters
my console bully me pls help 
how do i make a 'only visible to you' message from interaction in a server
like drop down
my mistake?
@full valley
@unkempt canyon
@trail flower
help me plz
1st, don't @ people wtf is wrong with u
2nd, you didn't save and restart
LMAO YEA
Nice
Yeah already told that around 3 weeks earlier
Yeah here

5 hours ago
Very useful ping by the way
Ephemeral message, depending on the library you're using you can add a hidden=True kwarg or similar when sending the message.
I am using dpy 2
If you're using discord.py 2.0 it's ephemeral=True apparently
Thanks!
How can I wait for the member response and take an example, write your name, then write the member and say to him, write your age
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
@client.command(pass_context = True)
async def mute(ctx, member: discord.Member):
if ctx.message.author.server_permissions.administrator:
role = discord.utils.get(member.server.roles, name='Muted')
await ctx.add_roles(member, role)
embed=discord.Embed(title="User Muted!", description="**{0}** was muted by **{1}**!".format(member, ctx.message.author), color=0xff00f6)
await ctx.send(embed=embed)
else:
embed=discord.Embed(title="Permission Denied.", description="You don't have permission to use this command.", color=0xff00f6)
await ctx.send(embed=embed)
nothing shows up
when i run it
imagine copying code
anyways server doesnt exist
use guild instead
And change
await ctx.add_roles(member, role)
to
await member.add_roles(role)
oh
And yeah, don't copy paste code
meh = time.datetime.now() + time.timedelta(seconds=timed)
meheh = meh.strf('%A %d %B %Y at %H:%M:%S %p')
await ctx.send(meheh)
Command raised an exception: AttributeError: 'datetime.datetime' object has no attribute 'strf'
```...wut do i do?
Pretty sure it's strftime
doesntwork tho
it only works in one server
Because the role doesn't exist on the other
wellllll yea...so wut do i change?
Don't write strf but strftime........
..aighty
still doesnt
it doesnt work in my own server
only in my friends one
How to change bot's pfp ?
Developer portal
what role
the Muted?
Yes
using discord.py
bot role above the muted role?
developer portal
bot.user.edit(avatar=image)
image needs to be a bytes-like object
Code: ```@tasks.loop(minutes=60)
async def send():
channelAutomeme = bot.get_channel(903173605364469770)
content = requests.get("https://meme-api.herokuapp.com/gimme").text
data = json.loads(content,)
response = data['url']
await channelAutomeme.send(response)
@send.before_loop
async def before():
await bot.wait_until_ready()```
Error:Unhandled exception in internal background task 'send'. Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop await self.coro(*args, **kwargs) File "main.py", line 471, in send await channelAutomeme.send(response) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1065, in send data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request raise Forbidden(r, data) discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
halp
your bot does not have enough permissions
your bot can't send a message in the channelAutomeme channel
so you should make sure it has the send messages permission in the channel
how can I get user display name from specified guild?
YO TYSM IT WORKS
you're welcome
why my tasks.loop() does not works ?
what's the error?
it works
"does not work" isn't helpful for anyone, send the error
no error but doesn't loops the function
send code
did u import discord.ext tasks
he said no error
hmm
have you started the loop?
Yes
ok
(loop).start()
yes got it
where should I get member?
!d discord.Member.nick
The guild specific nickname of the user.
“The 10 minute cooldown for changing avatars was brought in to stop people from abusing the avatar function using scripts to create a free 'animated' avatar.
Just as side note @patent surge
It's nick and not nickname.
discord.utils.get(guild.members, name=member_name)
Can I get user's nickname with that if I have their id?
ok i will use 5 minutes change avatar
10*
another way would be guild.get_member()
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Oof
is the ID correct?
Not in the guild then.
sure
what error
Unhandled exception in internal background task...
full backtrace
I thought I can get nickname through it
you get nick using member_object.nick
I decided to use this but still None
you're trying to print a member object
whereas you need a nickname
How to change the bots pfp using discord py
homo i need to get list of members of the server , how to
guild.members
with open('image.png', 'rb') as image:
await client.user.edit(avatar=image)
``` ?
thats it?
returns a list of the members inside the guild
okk ty
yes
Do you mind showing what your code is really quick. Id like to see the intentions just to make sure there’s no redundancy.
Spare my life please :(
forgot to delete
It’s a good thing I asked. Because this is just awful.
Is there any difference between Client and Bot? @dapper cobalt
Yes ||no||
If you want the message authors nickname. Literally just do
message.author.nick
Yes
Yes.
I need to get nickname from specified guild
Here they are
You have many useless variables. Could you please send your code?
bot.get_guild(id).get_member(id).nick
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
one-liner
Why? Why not message.author.nick?
depends on if he wants to get the nick of the message author or another member
!d discord.Message.author
import discord
from discord.ext import commands
client = discord.Client()
@client.event
async def on_message(message):
if not message.guild:
if message.author.id != 811223402308042792:
avatar = client.user.avatar_url
id = message.author.id
username = await client.fetch_user(id)
image = message.attachments[0].url
message1 = message.content
await message.add_reaction('👍')
channel = client.get_channel(907619999114489886)
guild = client.get_guild(886255929044111420)
display_name = discord.utils.get(guild.members, id=message.author.id)
print(display_name)
try:
embed = discord.Embed(title="Новая фотокарточка", description=message1, color=0x2F3136)
embed.set_author(name=f"{username}", icon_url=avatar)
embed.set_image(url=image)
await channel.send(embed=embed)
except:
embed = discord.Embed(title="Новая фотокарточка", color=0x2F3136)
embed.set_author(name=f"{username}", icon_url=avatar)
embed.set_image(url=image)
await channel.send(embed=embed)
else:
if message.author.id == 811223402308042792:
await message.add_reaction("👍")
await message.add_reaction("🍞")
await message.add_reaction("👎")
@client.event
async def on_ready():
print('Запущено')
client.run('')
He clearly wants the author's one.
argument must be bytes like object
I output discord username now but want to output nickname
like
you tried to use a variable before defining it
that's how it looks now
asking for a friend, how many messages can a discordbot send before not being able to? (per min)
5 requests per 5 seconds
huh
Unknown. Discord would never let such info become public; because then people might abuse it.
Can bots send friend request?
Wdym. They make ratelimit info public in the actual api server.
import discord
from discord.ext import commands
client = discord.Client()
@client.event
async def on_message(message):
if not message.guild:
if message.author.id != 811223402308042792:
guild = client.get_guild(886255929044111420)
display_name = guild.get_member(message.author.id).nick or message.author.name
await message.add_reaction('👍')
channel = client.get_channel(907619999114489886)
embed = discord.Embed(title="Новая фотокарточка", color=0x2F3136)
if message.content:
embed.description = message.content
embed.set_author(name=message.author.name, icon_url=client.user.avatar_url)
embed.set_image(url=message.attachments[0].url)
await channel.send(embed=embed)
else:
if message.author.id == 811223402308042792:
await message.add_reaction("👍")
await message.add_reaction("🍞")
await message.add_reaction("👎")
@client.event
async def on_ready():
print('Запущено')
client.run('')
Edited.
why does my bot print this everytime it starts up lol
main.py:80: RuntimeWarning: coroutine 'Command.__call__' was never awaited
funny enough, line 80 has nothing in it
Guyz
How to get byte like objs
How To False Add Reaction ?
AttributeError: 'User' object has no attribute 'nick' 
must be member object
example ticket tool
show ur code
@bot.listen()
async def on_message(message):
if "dropping" in message.content:
if message.author.id == 603446902393929728 or 646937666251915264 or 815289915557675118 or 707787324469280799:
if "3 cards" in message.content:
n = 4
elif "4 cards" in message.content:
n = 5
elif "2 cards" in message.content:
n = 3
attachment = message.attachments[0]
a = attachment.url
r = api.ocr_url(a)
buf = io.StringIO(r)
char = []
for i in range(1,n):
try:
x = buf.readline()
dict = ani.search.character(x, page = 1 , perpage = 1)
a = dict['data']['Page']['characters'][0]['favourites']
b = dict['data']['Page']['characters'][0]['name']['full']
if a < 301:
rarity = "Common"
elif 300<a<1001:
rarity = "Uncommon"
elif 1000<a<2401:
rarity = "Rare"
elif 2400<a<6001:
rarity = "Exotic"
elif 6000<a<10001:
rarity = "Legendary"
elif 10000<a:
rarity = "Godly"
try:
ping =get(message.guild.roles, name=str(rarity))
pm = ping.mention
except :
pm == "NO-PING"
pass
print (pm)
except:
pass
try:
c = str(i) + ". "+"**Character:** "+str(b)+" **Rarity:** " + str(rarity) + " :CH_wink:" + "**Ping:** "+ pm
char.append(c)
ch = '\n'.join(char)
except:
pass
await message.reply(ch)
print ("dropped")
keep_alive()
bot.run(token)
where is the mistake here?, it was working before i added the keep alive
My bad, I fixed it.
False add reaction?
👀
show what
Do you mean remove a reaction?
there is literally nothing in line 80
if i want to send to a specific channel shouldn't
channel = bot.get_channel(810282417850941440)
await channel.send(text)
work?
.
sry wrong reply
How to I change bot's pfp ?
Someone explain me how do I get this
How to make a time check function? I am making a mute command and I need to make a function that, after a person is muddied, will check whether the mutation period has ended or not
It failed to do what's inside the try statement, therefore ch is undefined.
Still having that issue
you can use the datetime library. I would recommend sleeping asynchronously after the user is muted and unmuting them after the sleep period is over
Something like that?
asyncio.sleep(we can only keep seconds?)
yes
ah
use 60*60 for minutes
e.g
asyncio.sleep(60*60) # sleeps for 60 mins
Guyzzzz How to False add reaction ?
okk
You mean remove a reaction?
example tikcet tool
!d discord.Message.remove_reaction
await remove_reaction(emoji, member)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Remove a reaction by the member from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.
The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
I don't think you can add to a datetime object?
if i want to send to a specific channel shouldn't
channel = bot.get_channel(810282417850941440)
await channel.send(text)
work?
Honestly I’m not too fond of sleeping commands for reasons like that. Completely halts the full execution of the functions which isn’t that nice. Consider loop.call_later() or something
that's why I suggested asyncio.sleep
I want to make it possible to stir up for a few hours, days, weeks, and if the bot is rebooted, then the mut will not be removed at the end
yes
I’m not saying it blocks but it doesn’t allow the full execution of the command
i is none
you'll have to store the unmute timestamp somewhere
'i' must be a channel id
whatt does it print
hmm what shud it do , tell that and i will telll u
Yes, I am using a database, mongodb
it print's the correct number
i is not a channel id
it is, just double checked
Plus If you don’t use sleep you don’t have to worry about converting your time to seconds. You can do all the unmuting and time handling into some function that you can pass into call_later()
@slate swan
i suppose u wont ur bot to spam messages on that specific channel?
whats x
ye
what does it mean? I don't quite understand what you want to say
ohhh u mean it shud send text in random channels?
my 3channels on MY discord server (i'm giving a notification to multiple channels with different people on them)
ohh
Bruh. What’s the point of casting. Just remove the quotes off the ids in that list.
u can do
await channel1.send()
await channel2.send()
await channel3.send()
the channels will change over time
or just loop through the channels
hmm
Ok so what does that have to do with you not removing the quotes 🤔
the id that you pass on to bot.get_channel must be an integer
the fuck, it started to work after that
thanks iguess?

