#discord-bots
1 messages · Page 485 of 1
Ok, so you just invalidated your own point about .env files
i make my token an import like
token = input("token: ")
that seems annoying
nah its not that bad
Seen a lot of selfbots do that
i always have the dev page open anyway
I made my token like
bot.run("literally my token")
every selfbot has that or a json
CLI anything in discord.py is just sus
xd
i could report so many of my friends for selbotting
but they will get caught eventually so
tell them to stop

partner in crime i see
they only use it for like fun commands
eh?
and activity
I hate self-bots
even though you can set your own 😹
they spam me and I can't reply
inb4 person accesses some random endpoint and gets their discord account terminated
Changing role colour and activity every miliseconds🗿
can't
immediate block
Discord has said specifically no rainbow roles
bro its so annoying because i used to nuke WHICH I AM NOT PROUD OF AT ALL AND DO NOT DO IT MY FRIEND GOT ME INTO IT AND ITS HOW I GOT INTO CODING but and now when i make a new account it gets phone locked and stuff, its mad annoying
kekw
🤣
that's karma at maximum
should've used your brain
(if you have one)
it used to be so fun, then once i kept getting termed i realized it wasnt worth it now i cant even buy nitro 😹
What's the point tho
yeah, feels bad not wasting 5$ on discord cool stuff
it was entertaning, to nuke like a crazy big server and watch the bans go up
and epic games just throws it to millions of people in 3 days
Ok we should not discuss bout this
fits your name
lol
can't imagine how many times you broke the ToS
it's crazy ever since i stopped you guys have actually helped me a lot and made coding fun
and you're still here
i can't even count
but i don't break it anymore so
the most i've done was log into my friends acc with his token 😹😹

"i was doing crime and i am not doing it anymore therefore i am innocent"
he's still in jail
i was doing crime that is illegal on discord.com
can't make a new account or buy nitro
.gg
well deserved lol
i was gonna try and become a discord staff but i know that would be 99% impossible because of what ive done
LOL
I think-
I think that chance is a bit more than that
99.1 lmao
is that even python
Wouldn't a decompiled pyc file be just the regular py file

Marshal data is something I've never heard
no
im banned cuz i wouldnt change my bots prefix 😹
bot prefixes can be annoying though there
bro what
you’re trying to test your bot and 50 million random bots appear
oh lol
I never go there
rs i told them i had a cmd to change it and that danny could change it if he wanted to
but they didnt care
I always wonder why everyone's an asshole there
If you are the bot owner why can't you
they’re assholes to people who pretend to know what they’re talking about aka skids
i didnt have permissions
at the time i didnt know that i could make a cmd work for a certain id
Is using a local filesystem (JSON format) appropriate for a small-scale client?
if you want something file based use sqlite
its a database
and it’s fairly lightweight
I am going to come across as a bit inexperienced here, so apologies in advance, but could I ask the advantages of a database on a small-scale? I should really learn them at some point... I'm really procrastinating it, but I don't fully understand their uses
From what I know files are dangerous to work with in case it might be accessed from multiple points... or maybe speed? But I know very little about the details
(Regardless though thank you for the suggestion and I will check it out)
I dont understand what TypeError: 'int' object is not iterable is.
@client.command()
async def leaderboard(ctx):
for current_user in report['users']:
lvl=current_user['level']
newlvl=sorted(lvl)
print(newlvl)
Error:
Ignoring exception in command leaderboard:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 381, in leaderboard
newlvl=sorted(lvl)
TypeError: 'int' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not iterable
oh it's not that actually
report['users']
returned you a single int
not really
oh lol
I printed out lvl and it gave me
should've been more careful
well it is a string then...
bruh it's too late for me
it's most likely a string with numbers split by newlines
oh ur right
How do I make them a int
I need more info about your variable lvl
debug it with print(type(lvl), repr(lvl))
should be enough
<class 'int'> 3
<class 'int'> 8
<class 'int'> 0
<class 'int'> 2
<class 'int'> 0
<class 'int'> 0
<class 'int'> 0
<class 'int'> 7
<class 'int'> 0
<class 'int'> 0
<class 'int'> 0
<class 'int'> 2
<class 'int'> 0
<class 'int'> 0
<class 'int'> 0
<class 'int'> 0
<class 'int'> 0
<class 'int'> 0
gave me that
this was a long time ago lemme renew it
oh that's multiple print statements then
i think your issue is how you're thinking about this
when you do leaderboard, it's called multiple times with only a single lvl variable
as you see there, each time a <class 'int'> number is printed, that's bc leaderboard has been called, and that's lvl
when you do sorted(lvl), you're sorting a single number
How would i sort all of them
which to python obviously makes no sense, int is not iterable
well you'd need to store all of the levels
so that you have a variable which contains something you can actually sort
which has all the data you want
newlvl = sorted(u['level'] for u in report['users'])
print(newlvl)
>>> [0,0,0,0,1,2,3,7,8]
i was mistaken - the issue is probably because you're iterating over a single item but treating it as the entire list
how would you reverse the list
reversed(list_object)
newlvl = sorted(u['level'] for u in report['users'], reversed=True)
would this work tho?
that would, although the keyword argument is reverse, not reversed
really? actually that's weird. regardless:
sorted([u['level'] for u in report['users']])
wrap it in square brackets. (regarding the error, i thought you could forego parentheses for generator expression if it was inside a function's parentheses)
thanks
actually, could i ask what version you're using?
interesting, ty
Hey guys, what is the best choice? Pycord or Nextcord?
i tried this to show user activity no error but would not respond
@client.command
async def status(ctx):
await ctx.send(ctx.author.activities[0].name)```
what is ctx?
it’s a context object which i believe is defined in discord.ext.commands
oh ok
also @lyric moat try printing it out to the console
i would look through the documentation to see why your code isn’t working but honestly it’s just faster to have you debug it lol
it gave me something to import and it still do not work
kk
what is mins supposed to be
@lyric moat could you print the output from the console? discord.Member is just a standard object type in the discord library, idk what u mean by it gave you it to import
that is basic python, you are calling a var that isnt defined yet
like getting something out of thin air
no error or nothing called the your check isnt being called
i dont really understand this
@ everyone role is in every channel
by not checking for that?
well like i said
its a weird check
how can i use from discord.ext import commands
General discord API question. Directly interfacing with the gateway API yields me a HELLO on connect, when i send back HEARTBEAT and then IDENTIFY, the next message i get from the gateway is a CLOSE with code 1002. I have been told it's because the payloads for what i sent are wrong, but idk what exactly is wrong.
communication
{"t":null,"s":null,"op":10,"d":{"heartbeat_interval":41250,"_trace":["[\"gateway-prd-main-1bw8\",{\"micros\":0.0}]"]}}
sent identify
WSMessage(type=<WSMsgType.CLOSE: 8>, data=1002, extra='')
HEARTBEAT
async def heartbeat(self):
"""Send HB packet"""
payload = {
'op': self.HEARTBEAT,
'd': self.sequence,
'compress': True,
}
await self.socket.send_json(payload, compress=9)
IDENTIFY
async def identify(self):
"""Sends the IDENTIFY packet"""
print("sent identify")
payload = {
'op': self.IDENTIFY,
'd': {
'token': self.token,
'properties': {
'$os': sys.platform,
'$browser': 'disthon.',
'$device': 'disthon',
},
'compress': True,
}
}
await self.socket.send_json(payload, compress=9)
whats the difference of discord.Bot and commands.Bot?
one exists and the other one doesn't
oh
@bot.command()
async def banner(ctx, user: discord.User=None):
await ctx.message.delete()
if user == None:
r = requests.get(f"https://discord.com/api/v9/users/{bot.user.id}", headers={"Authorization": "Bot " + TOKEN}).json()
if r["banner"] == None:
embed = discord.Embed(description=f"You don't have a banner.", color=0x2f3136)
embed.set_footer(text=footer)
embed.set_author(name=f"{ctx.author} ({ctx.author.id})")
await ctx.send(embed=embed)
else:
embed=discord.Embed(description=f"Here is, **your**'s banner.\n\n[png](https://cdn.discordapp.com/banners/{ctx.author.id}/{r['banner']}.png)\n[jpg](https://cdn.discordapp.com/banners/{ctx.author.id}/{r['banner']}.jpg)\n[gif](https://cdn.discordapp.com/banners/{ctx.author.id}/{r['banner']}.gif)\n",color=0x2f3136)
embed.set_footer(text=footer)
embed.set_author(name=f"{ctx.author} ({ctx.author.id})", icon_url=str(ctx.author.avatar_url))
embed.set_image(url=f"https://cdn.discordapp.com/banners/{ctx.author.id}/{r['banner']}.gif?size=4096")
await ctx.send(embed=embed)```
Always says you don't have a banner even if you have one, and I have no clue what to do lol
why are you using requests tho
I'm using below 2.0
that...does not matter
.banner doesn't work below 2
requests in dpy have always been a bad thing since the start of the library
But why
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
i know about async blocking
I didn't know they block async
i don't feel like not using requests
requests isn't async so it's blocking
aiohttp is async and doesn't block
easy as that
how can i use await commands.MemberConverter.convert() accurately? i see no description in the docs of supplying the id= or name=, so if i add (ctx,argument) it asks for the argument? confused
and strange, you should print out the request and see what it all contains
@commands.command()
async def foo(ctx, member: discord.Member):
# code here
there now you used the converter
yeah i cant use typehint converter for this module
it just contains the banner, i had it working on a mention, just not self.
purposefully
i mean you're adding yourself a lot more hassle...for what seems no reason,
Anyways you get the on_message, which gets processed by the bot internally, or in an on_message event using process_commands
This gets the context, and invokes it. ctx.invoke is a shortcut (with extra stuff) for ctx.command.invoke so it goes there
This invoke call calls prepare on the ctx. Prepare does the last bits and things like parse the arguments. This can be found here: https://github.com/Rapptz/discord.py/blob/45d498c1b76deaf3b394d17ccf56112fa691d160/discord/ext/commands/core.py#L816
Parsing the arguments is done here: https://github.com/Rapptz/discord.py/blob/45d498c1b76deaf3b394d17ccf56112fa691d160/discord/ext/commands/core.py#L700
This part runs the converters.
discord/ext/commands/core.py line 816
await self._parse_arguments(ctx)```
`discord/ext/commands/core.py` line 700
```py
async def _parse_arguments(self, ctx: Context) -> None:```
yeah thanks man, worked. but it still called the error i was having problems with earlier 😭
haha
need a different method to ban a user in the same command, and adapt to the user being in the server and not
just typehint to discord.User
and do guild.ban(user)
works for both members in and out of the guild
!d discord.Guild.ban
await ban(user, *, reason=None, delete_message_days=1)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
i see, thank you
a few days ago I asked for help with this problem, someone told me to try enabling the attempts, but the same problem is still happening
code is here
discord will only tell the bot what the invite code was of the deleted invite. The user and such must be cached by your client. If not then it's just None
intents is a requirement for this caching, and for the rest it's just.....whatever happens
bot.get_channel isnt a coroutine you have to use await bot.fetch_channel
or remove await
fetch_channel uses the API, get_channel is from cache iirc
yep
just a better idea to use get_channel whenever you can
he uses .send in the same line, he has to use await
only noticed that just now
oh yea i didnt notice that either
noted, thanks guys
hi, just wondering if its possible for me to write some code inside main.py and have it trigger learn and generate to run
thats possible.
sorta
meaning every message triggers the learn app to learn it
uhhh yeah thats possible
may i ask how?
let me make an example brb
permissions = ch.permissions_for(ctx.author)
AttributeError: 'Object' object has no attribute 'permissions_for'```
what is this error
what ever variable ch is does have the attribute permissions_for
ck.permissions_for doesnt exist
i have no ch variable lmfao
Can you send your code?
post your full code
@bot.command()
@commands.has_permissions(administrator = True)
async def setprefix(ctx, new_prefix):
await bot.db.execute('UPDATE guilds SET prefix = $1 WHERE "guild_id" = $2', new_prefix, ctx.guild.id)
embed = discord.Embed(description=f"Prefix has been updated to {new_prefix}", color=0x2f3136)
embed.set_footer(text=footer)
await ctx.send(embed=embed)```
Error happens with that command
I would like to verify members by sending a code to their mailbox (of our organization) and let them send it back to the bot. To verify that they are from the organization...
Is there something like this?
Does it work without the has_permissions decorator?
I'll check
Brings a error
await bot.db.execute('UPDATE guilds SET prefix = $1 WHERE "guild_id" = $2', new_prefix, ctx.guild.id)
AttributeError: 'NoneType' object has no attribute 'id'```
Where are you running this command from?
Wdym?
This is a discord bot command. Where are you running the command
In my server
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
File "main.py", line 59, in setprefix
async def setprefix(ctx, new_prefix):
AttributeError: 'NoneType' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'```
There's that if that helps lol
I'm just a bit confused as to why ctx.guild is None
Maybe a DMChannel?
They say they're doing it in their server
@honest wing Can you print out the type of ctx?
print(type(ctx))
def?
like if I want to make a function _Example example
function I mean
You can't have spaces in function names
where @? in the command?
ok
with your DB stuff
Sorry, this dosen't make it any clearer
Traceback (most recent call last):
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 943, in on_message
await self.process_commands(message)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 940, in process_commands
await self.invoke(ctx)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 851, in invoke
await self.prepare(ctx)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 778, in prepare
if not await self.can_run(ctx):
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 1076, in can_run
return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\utils.py", line 338, in async_all
for elem in gen:
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 1076, in <genexpr>
return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
File "C:\Users\misery\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 1762, in predicate
permissions = ch.permissions_for(ctx.author)
AttributeError: 'Object' object has no attribute 'permissions_for'```
let me get a help channel
Ok, something is happening that might be messing with your context object
What version of dpy do you have?
I think it's ```py
discord.version
the command was working earlier though, idk what happened
1.4.2 > all
hi pookie bear
huh
intents = discord.Intents(messages=True, members=True)
member_cache_flags = discord.MemberCacheFlags.none()```
```py
intents=intents, member_cache_flags=member_cache_flags```
was messing it up for some reason, thank you guys tho
how do you make a command cooldown for every 5 seconds?
i believe it's
@commands.cooldown(1,5 BucketType.user)
@rugged tinsel
i could be wrong
You missed a comma
wait where?
1, 5,
ooh
Also you should of sent the documentation
can anyone help #help-popcorn
i couldn't find it
You could of just searched for it
hm
hi, how can i make my bot create an invite for the guilds it is in? i have the guild ids
I got banned for using a python bot 😟
?
how can i make server banner command?
wht do u mean ?
u want a bot to add a server banner ?
yeah and like show the server banner
You guys know of a way to have the bot periodically execute a subroutine?
@surreal creek I made a bot through python and it was flagged saying it was a self bot 🥺
hmm
then idk
ok how i make it show the server banner?
no 😦
sry
idk
Ya my main account got disabled does anyone know or if my account will be undisabled
I put in a claim
idk
wait lemme send a sample code
Welp rip my nitro 😭
Thanks
import asynciot#The only thing u need to import
async def forever():
print('Task Complete')
asyncio.sleep(15)
bot.loop.create_task(forever())
Ah okay, you can create a task with the bot
I'm pretty sure there's something in discord tos about privacy for servers and by joining them through your bot would be breaking tos
ur code ?
cool thanks
@client.command()
async def banner(ctx):
if not ctx.guild.banner:
embed = discord.Embed(title="Server has no banner!", color=0xf7fcfd)
return await ctx.send(embed=embed)
else:
embed = discord.Embed(title=f"Banner of {ctx.guild.name}", color=0xf7fcfd)
embed.set_image(url=ctx.guild.banner_url_as(format='png'))
await ctx.send(embed=embed)
await ctx.send(embed=embed)```
ah i seee
btw how i make it the same size as the banner?
@client.command()
async def banner(ctx):
if not ctx.guild.banner:
embed = discord.Embed(title="Server has no banner!", color=0xf7fcfd)
return await ctx.send(embed=embed)
else:
embed = discord.Embed(title=f"Banner of {ctx.guild.name}", color=0xf7fcfd)
embed.set_image(url=ctx.guild.banner_url_as(format='png'))
await ctx.send(embed=embed)#THIS IS FIRST TIME
await ctx.send(embed=embed) #THIS IS SECOND TIME
idk that 😐
@lyric moat
check the comment
still sends 2 times
resend ur code
oh hmm true
^^
well tenks dodged a bullet
delete the last await ctx.send(embed=embed)
in the last line
thanks
your welcome
btw this is the second time I helped anyone over here :]
It will send twice cz it's trigerring the else clause
The first @commands.command() works, but the second one throws an error, is there a reason for this? I'm not sure what's going on here
For future reference, I found that there is a built in decorator for this kind of thing: https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html
can you send the error
AttributeError: 'Command' object has no attribute 'command'
oh, do you have a command named commands?, rename it
ohk
yeah rename it, because it is overriding discord.ext.commands
i did not go that proffetional coz i use this trick for my bot's status
weird, the bot still isn't detecting commands
I ran into problems with it only executing once. Not sure why
oh I have client.command not client.add_command
send that part of ur code
ohk
okay changing that doesn't work
I'm using cogs, so @tasks.loop was perfect
So, I'm using @commands.command(), does that not work with client.add_command()? At the start I do have client = commands.Bot(command_prefix='?')
ohk
When I did everything in client.on_message(message) it worked (but that's a pretty bad solution), but this isn't working, I haven't really used discord.ext before though
use client.command()
async def bla bla bla
?!?
@young torrentmands.command()
tf
ye
@commands.command()
use @client.command()
ah, I tried that
i dont think there is such a thing :/
!d discord.ext.commands.Command
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
actually let me repaste that to censor something
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.
@surreal creek
Thats for commands in cogs lol
What about the code in this?
is there an error in the code?
Weird, commenting out all the code except for that works, but all the code doesn't work
make an error handler so you know whats the error lol
apparently the issue was my on_message code
is ther on_message in ur code ?
i am finding that itself
coz normaly these things create probs
This might be your issue
#discord-bots message
yea
Does it work?
Should work
says bad request, unknown emoji, but the emoji does exist, I might have the emoji ID wrong, but I don't know how to return an emoji id
is the emote
I thought you just right click and press copy id
no ,
mb
You need to use :emoji:
?
oh
Isn't that what they have though...
You can get the ID by right clicking on it
wanting to catch when someone posts a link, and the link does not embed
i used
if len(message.embeds) == 0:
but it wouldnt catch it,
can you show an example for This emoji 
It's working now.
hmmm
I appreciate the help guys!
¯\_(ツ)_/¯
strange, used to work for me
\:emojiname:
889705308530823188 is actually the message id
Blame discord for that :0
is there any way to play audio files in discord without using ffmpeg? bcoz i am using replit :(
So anyway, @worthy wagon if that isn't working for you, you may need to get the emoji object and pass that instead
Lavalink , same issues with youtube tos exist tho
not only youtube i am talking about all kind of music. suppose i have a music in my replit and i want to play it in a vc by my bot. how can i do that? and i believe that ffmpeg don't work with replit
Ffmpeg works with replit
and you can use it if you want to play some locally stored files
I feel like saying that ffmpeg "works" is a bit weird, since replits filesystems are ephemeral
I don't even know how you would really install it
haven't really done anything with he voice client yet:/
you can find couple of docs related to it
Isn't that just the python bindings?
The github page dosen't seem to exist either
https://github.com/jiashaoku/ffmpeg
yeah , and it configures it to work with ffmpeg
Heyy, I've got a question
I need help making a custom command and this is how I want it to work. I want to be able to store a users name in it. So the command would start of blank like !channel and the output would be None! Set one now!. Once I set it like !channelset @user I want that to be channel specific. So If i do !channel in another channel, it would say None! Set one now!. However, if I do it in one that has been set, it would give me user output like @user. Any idea on how to do so?
Well, it looks like it needs ffmpeg installed
@slate swan ?? Can you help?
Hmm, seems to work, weird that it does that
Whats the error?
Heyy, do you know how to read discord embeds?
For the 10th time no
sure
i dmed you
Define "doesnt work".
@client.command()
async def transcript(ctx):
await ctx.message.delete()
with open("file.txt", "w") as file:
msg = await ctx.channel.history(oldest_first=True, limit=1).flatten()
y = msg[0].mentions[0]
file.write(f"{ctx.channel.name} | {y.name}" + "\n \n \n")
async for message in ctx.history(limit=None):
file.write(str(f"[{message.author}]: {message.content}" + "\n"))
with open("file.txt", "rb") as file:
await ctx.send("Your file is:", file=discord.File(file, "transcript.txt"))``` How can I make the order of the messages flip so the oldest message is on the top rather than on the bottom?
Ahhh, thank you!
Ah, that was a place holder for when I got back to it, I thought I needed to use .reverse
!d discord.Message.embeds
A list of embeds the message has.
🙂
And for the {y.name}
oh okay
`Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'datetime' has no attribute 'now'
172.18.0.1 - - [21/Sep/2021 04:01:29] "GET / HTTP/1.1" 200 -
Code?
^
You need to do datetime.datetime.now()
try datetime.datetime.now()
You imported it as import dateteime rather then from datetime import datetime
so like this?
Yes datetime is the module and datetime and time are the sub modules
i see
hi, how can i check if 2 messages with the same thing have been sent? i have no idea how to do it lol
Then learn Python.
And to get the message's content, it's message.content.
!d discord.Message.content
The actual contents of the message.
alright thanks
any docs page they have?
async for message in ctx.history(limit=None, oldest_first=True):
time = datetime.now(tz=pytz.timezone('America/Tijuana'))
msgtime = message.created_at.strftime({"%I:%M %p"})
file.write(str(f"({msgtime}) [{message.author}]: {message.content}" + "\n"))``` How could I set the msgtime time zone to America/Tijuana?
Doesn't datetime.now grab your systems current datetime?
It doesn't because it says it's 4:00 am, but in reality it's 10:00 pm here, plus I can't use my local time xd
Lemme quickly do some googling
https://stackoverflow.com/questions/36067621/python-all-possible-timezone-abbreviations-for-given-timezone-name-and-vise-ve Maybe something like this will make sense?
hi i'm trying to make my bot send something if a previous id has been seen but it returns with
with open("previousids.txt") as file:
previousids = [previousids.strip().lower() for previousids in file.readlines()]
@client.event
async def on_message(ctx, message):
if any(previousids in message for previousids in previousids):
await ctx.send('this id has been seen before. bruh moment')
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)
TypeError: on_message() missing 1 required positional argument: 'message'
Hmmm- not sure how I could use that
On message event have only message parameter not ctx
oh.
message.channel.send
hmm ok thanks :D
hmm then returns with
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 63, in on_message
if any(previousids in message for previousids in previousids):
File "main.py", line 63, in <genexpr>
if any(previousids in message for previousids in previousids):
TypeError: argument of type 'Message' is not iterable
What are you trying do?
make the bot send something when a certain word in a txt file is sent
hmm ok i'll try
So im making a custom prefix command using mongodb, and when i use the setprefix command, it adds the info in the collection, but i also get this error, and the new prefix wont work:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Bot' object is not callable ```
My code:
```py
@client.command()
async def setprefix(ctx, prefix):
db = cluster["discord"]
collection = db["prefixes"]
guild_id = ctx.guild.id
server_prefix = prefix
if(collection.count_documents({})) == 0:
prefix_info = {'Guild_id': guild_id, 'Prefix': server_prefix}
collection.insert_one(prefix_info)
else:
prefix_info = {'Guild_id': guild_id, 'Prefix': server_prefix}
collection.update_one({'Guild_id': guild_id}, {'$set': {'Prefix': prefix}})
await ctx.send(f"My prefix is now {prefix}")
finding_prefix = collection.find_one({'Prefix': {'$eq': prefix}})
view_finding_prefix = finding_prefix.values()
iterate_view = iter(view_finding_prefix)
first_value = next(iterate_view)
client(command_prefix = str(first_value), case_insesitive = True)
?
and this is after the
client = commands.Bot(command_prefix = '!', intents = discord.Intents.all())
```line
Error line?
This is after your command?
before
Show me full error
alright one sec
ret = await coro(*args, **kwargs)
File "c:\Users\-----\Desktop\Python\Projects\discord bot\DiscordBot.py", line 46, in setprefix
client(command_prefix = str(first_value), case_insesitive = True)
TypeError: 'Bot' object is not callable
@slate swan
would moving the code into a cog fix it?
uhh
No. Your way is wrong
not really.
?
If your code won't work outside of the cog it won't work inside of the cog
You currently have a prefix set. You create a command in the wrong way that will change the original prefix. This cannot be done this way.
If you think more about it you will found why cant do that
Specifically you are trying to change the original prefix to something else for all the servers that are your bot, not for each one individually.
do you know any way to do it properly?
Maybe this fix your error
client = commands.Bot(prefix=str(first_value), case_insesetive=True)
i'll try it
In this video, we will learn how to make a system where users can set custom prefixes for a Discord bot in python using discord.py, postgreSQL and asyncpg. This is the rework of the video where I showed how to do the same thing with JSON, but here it's with a database.
You'll need to pip install asyncpg if you don't already have it installed!
...
I suggest check this tutorial
you cant call it
i was using this video before, but it uses postgre, and it was hard to follow
i'll try rewriting the entire thing once
Build the structure
Who here can help me make a Paginator which will divide the string if the number of new lines exceeds the number I specify?
i want to ask my bot to make the invite to my server like choi!mi 25 will make a invites with maximum 25 uses what do I write in the code
!d discord.TextChannel.create_invite use the max_uses kwarg
await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates an instant invite from a text or voice channel.
You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
and how can the bot send it
just like u send a simple message bro
invite = await channel.create_invite()
await ctx.send(invite)
it say undefined name create_invite
....?
yes
opinions? left or right for formatting?
code
I think the second one
also adding a color will be better
hi, when i run this why does nothing happen when i run t!help?
import os
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='t!')
TOKEN = os.environ['mrow']
@bot.command
async def stoopid(ctx):
await ctx.send('no')
@bot.event
async def on_ready():
print(f"Logged in as {bot.user.name}")
print("---------------------")
with open('previousids.txt', 'r') as f:
global ids
previousids = f.read()
ids = previousids.split()
@bot.event
async def on_message(message):
for word in ids:
if word in message.content:
await message.channel.send('this id has been seen before')
bot.run(TOKEN)
How do you add color to an embed?
colour = 0x hex code here without
!d discord.Embed.color
No documentation found for the requested symbol.
The colour code of the embed. Aliased to color as well. This can be set during initialisation.
kekw
:blobpain:
yeah
wow it requires the u?!
No
no it doesn't
k good
read the embed. it can be color also
coz i was aboutta say. I'm australian but even i'm lazy and leave the 'u' out
sadge why no work
@unkempt canyon was just having a stroke
lmfao
disnake
hmm
🤷♂️ I use that and haven't got any problems till now
!pypi disnake
ok thanks!
help ples
on_message blocks commands
Unless there's a way to make on_message stop doing its nonsense, dont use it
oh hmmso i put the command after othe event
await bot.process_commands(message) at the end of on_message
ok tenks
wot.
\:crossed_swords:
Yea
the variable name for a constant
Does color change the font color or background color?
side bar
only the side one
this
Yea
Oh
lol it would be cool if i could change the background colour
It would be cool
thse are things you should try yourself, ask us bout errors
Na I dont want to spend 2hrs trying to change the font color or background color only to find out it doesnt do that
🤣
Easier to just ask questions
it will take a minute lol
It is fine. Calm down
can i set embed footer text to be a different color
XD not arguing
no
u can try codeblock
damn
how does this work?
for ?
it ust reinvokes the command
Hi, I'm re-creating (and not forking) discord.py (called Disthon) using the code form discord.py, discord.js and Sapphire framework.
I need programming experts to lend me a hand with the project. If anyone's interested in contributing, please reply to this message
bro... footer
lol footer no chance
oh sorry rofl
Haha, you should also ask from some people in #python-discussion
Dw I will
Thanks tho
I don't think anyone here (I think) is that genius to contribute to your project (At least idk anything about Python)
lol invalid syntax kekw
im mega poopoo
indent it outside the if statement
ok
root indent
mm ok
||)||
uhwaefiy
L
0
L
😎
Hey @keen talon mind helping me with something if u r free?
with what lol ? I have my entrance exams two weeks later
So I am trying to making a Paginator and the paginator should do something like...
There will be a dict, and the key value pairs of the dict will be divded in a group of 10 in case the length is more than 10... So, how can I split the dict key value pairs into groups of 10?
Is there any exception which checks whether bot is already in a vc upon a request for it to join?
sorry if my wording isn't clear 😅
ClientException
!d discord.ClientException
exception discord.ClientException```
Exception that’s raised when an operation in the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") fails.
These are usually for exceptions that happened due to user input.
idk man sorry

u know numpy ?
No
u can do array.reshape with the keys
Man. setting up all these bot.events is time consuming
So there's no specific exception?
What exactly is the ui type feature called?
like its a message which you can click different buttons and things on
bie cya
cya
||gui||
hmm ok
Buttons, Selects, Views
im talking about the discord bot thing....
hmmm ok thanks
damn
umm 👀
@bot.command()
Can someone tell me what a group channel is? is that what discord refers to as a thread?
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
So you can use paste ^
You get a notification whenever that happens? 🤔
issue?
you aren't use an f string
r=requests.get(" should be r=requests.get(f"
dw
I take forever to code coz I keep forgetting to do silly things like that
Not working
How to add emojis in embed pls tell
I'm trying
But not working
Ok
embed.add_field(name= " <emoji_4 889758662640422922> FUN COMMANDS", value= " 8ball, slap, hentai, boobs, neko, pussy, anal, blowjob, lewdneko" )
Share the correct code
Okk
That's the spirit
hi does anybody know how to only get the first few characters of something a user says?
hey uh, how do i send output of my terminal?
i tried this code but it sends 0 when i type sqd-t echo f
i use linux,
msg = message.content
reply = message.reply
sendmsg = message.channel.send
if msg.startswith('sqd-t '):
cmd = msg.split('sqd-terminal ', 1)[1]
print('')
print(msg)
print('Command requested: ' + cmd)
await reply('**Sending command to terminal...** `' + cmd + '`')
cmd = str(cmd)
await sendmsg('`Output:`\n\`\`\`' + str(os.system(cmd)) + '\`\`\`')
why does it do that?
ping on reply
gross man
any free web servers for bot?
sry for saying so
please tell me
wdym
replit
idk what to say
replit works for only 1 hour
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
Help pls
okay
.
Anyone knows?
Replit isnt a web server tho
i believe so, Invisible
oops
the code would help
Problem solved
discord.ext.commands.errors.ExtensionNotFound: Extension 'Moderation' could not be loaded.
What does this mean, something wrong In the main loading code or in the extension code?
the cog does not exist.
for cogs, it is @commands.command
prefixes = "", "c!", "C!"
bot = commands.Bot(command_prefix=prefixes)
Basically this right?
This Is what I have now, still the error.
prefixes=["first", "second", "third"]
But why, that what I use works always
Np
use a list
you should be focusing on that then lol
Oh wait, I am stoepid.
It says theres something wrong in the main script
File "/home/container/bot.py", line 16, in <module>
bot.load_extension("Moderation")
Traceback (most recent call last):
File "/home/container/bot.py", line 16, in <module>
bot.load_extension("Moderation")
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 676, in load_extension
raise errors.ExtensionNotFound(name)
discord.ext.commands.errors.ExtensionNotFound: Extension 'Moderation' could not be loaded.
I somehow recognize that 😂
how do i make the bot send a "this message is only visible to you" message
Oh I fixed It, moderation instead of Moderation but Now i get some sketchy error
Only discord can
noo i saw dank memer send me that sort of a message
slash commands or buttons can do that
ohh
how can i create a dashboard for my bot any resource
Try HTML or css to create a basic website then I advise looking into some forms
Like this you mean? @coral ermine
File "/home/container/moderation.py", line 11, in Moderation
@commands.event
AttributeError: module 'discord.ext.commands' has no attribute 'event'
see my bot is deployed on heroku and if i use flask or quart
!d discord.ext.commands.Cog.listener
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
how can i run that app
@commands.Cog.listener() is for events in cogs ^
@ionic wadi
yes yes this
@commands.Cog.listener()
async def on_ready():
channel = bot.get_channel(848262509244055622)
await channel.send("Moderatie Cog Ingeladen")
print("Moderatie Cog Ingeladen")
TypeError: on_ready() takes 0 positional arguments but 1 was given
I have no idea with heroku sorry
like i just need bot data
not user data
is there any way just to get bot data
?
add self parameter to it
@visual island any idea ?
nah
see i want to create a dashboard
but there a problem my bot is deployed on heroku so how can i run
flask or quart
with it
today = datetime.utcnow().strftime("%Y%m%d")
@commands.Cog.listener()
async def run_once_when_ready():
with open('daily_poll.txt','r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
Hey this is my code, The bot isnt printing anything nor is there any error 
@slate swan insert today with in the function
before file handler
I want to change the binary data from DB to jpg and send it to the user. Is there a way to send an image without saving it?
Short answer: no
Long answer: you can store the cdn link, but that won't work once the image is gone from the cache (can't remember how long cache stays)
Really you need to store the image if you want to guarantee the image will always be sent
Still no error, Doesnt print either
! help
!hepp
How to host discord bot?
Use money and free
?tag vps In dpy's server
if only he was in the server
@slate swan
If you need to run your bot 24/7 (with no downtime), you should consider using a virtual private server (VPS).
This is a list of VPS services that are sufficient for running Discord bots.
https://www.scaleway.com/
Based in Europe.
https://www.digitalocean.com/
US-based.
Considered by many to be the gold standard.
Locations available across the world.
https://www.ovh.co.uk/
France and Canadian locations available.
https://www.time4vps.eu/
Seemingly based in Lithuania.
https://www.linode.com/
Cheap VPS.
https://www.vultr.com/
US-based, DigitalOcean-like.
https://galaxygate.net/
A reliable, affordable, and trusted host.
There are no reliable free options for VPS hosting. If you would rather not pay for a hosting service, you can consider self-hosting. Any modern hardware should be sufficient for running a bot. An old computer with a few GB of ram could be suitable, or a Raspberry Pi (any model, except perhaps one of the particularly less powerful ones).
self.bot.loop.create_task(run_once_when_ready())
NameError: name 'self' is not defined
Wondering why I am getting this error?
def __init__(self, bot):
self.bot = bot
I have defined it in my init also
@slate swan i assume "create_task" is a function correct? if so, you need self before run_once_when_ready()
it's what i'd try anyway
Give it a shot and if it doesn't work then I'm all outta ideas
async def run_once_when_ready():
await bot.wait_until_ready()
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt','r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
self.bot.loop.create_task(run_once_when_ready())
Thats the code so you mean async def self.run_once_when_ready():?
Oh
Oh
there's your issue.
async def run_once_when_ready():
needs to be
async def run_once_when_ready(self):
Wym?
soz I pressed enter
make it self.run_once_when_ready()
and that
IDK THERE NEEDS TO BE A SELF SOMEWHERE AAHH
Oh okay thanks both of you! Lemme try that
My process is normally to add self everywhere until it works. i'm going back to being a derp.
hi i'm not sure why the below code has an output of the image. can somebody help?
@bot.command()
async def idlist(ctx):
lol = open('previousids.txt', 'r')
embed=discord.Embed(
title='id only log',
description=(lol),
colour=ctx.message.author.colour
)
await ctx.send(embed=embed)
kekw = open('reasons.txt', 'r')
embed=discord.Embed(
title='id and reason log',
description=(kekw),
colour=ctx.message.author.colour
)
await ctx.send(embed=embed)
@lofty heron i think it's coz you need to parse your lol into a string.
I say think coz like with @slate swan i'm taking a stab and guessing here. and that's where i'd start.
no.
that'll just print a "lol" in his embed
No what I meant was.
lol doesnt have string items in it. he needs to parse the contents of it into a string.
oh
Sorta like reading a json file. Sure you can open it up and pray to god it works right then. or you can process it into the parts you need/want and in a way you can read it
tenks
Although a json file isnt the best example since it's basically a list/dict
your lol is not text. you need to readline(or lines) from it with functions like lol.readline()
what? I don't quite understand what you mean
try
description=(lol.read),
ok i'll try
oh wait lol.readline() this?
yeah that
yea leave it blank if you wanna read a single line
wait i forgot the ()
description=(lol.read())
if you want to read all lines, use lol.readlines() but it will give you a list of lines
🤞 lets hope w3schools do us a solid for a change and has correct code
kekw
otherwise im off to stackoverflow
if you wanna print a list of lines, just use "\n".join(whatever you named the list)
@lofty heron are you trying to read a single line or multiple lines?
lol
multiple
Are you storing and updating everything in a .txt file? why not use a database? or json file?
hi tram
idk how to use anything else
wait how did u send 2 embeds in one message
oh hey
I commend you for making your database txt files. Perfectness. But if we're being smart, use json or database
do this:
@bot.command()
async def idlist(ctx):
lol = open('previousids.txt', 'r')
lines = lol.readlines()
lines = "\n".join(lines)
embed=discord.Embed(
title='id only log',
description=lines,
colour=ctx.message.author.colour
)
await ctx.send(embed=embed)
kekw = open('reasons.txt', 'r')
lines = kekw.readlines()
lines = "\n".join(lines)
embed=discord.Embed(
title='id and reason log',
description=lines,
colour=ctx.message.author.colour
)
await ctx.send(embed=embed)```
2 messages
ohh
2 seperate messages
oh
hmm ok i'll try
ty :D it works stonks
Since there's some smart people here. Can someone help me?
@commands.Cog.listener()
async def on_member_update(self, before, after):
channel = self.client.get_channel(889479625087021106) #Channel where this log will be sent.
print('Someone updated themselves!')
title = 'Someone updated themselves!'
msg = 'There was a disturbance in the force.'
if before.display_name != after.display_name:
title = f'Display name change of {after}'
msg = f'Old display name: {before.display_name}\nNew display name: {after.display_name}'
if before.status != after.status:
title = f'Status change for {after}'
msg = f'Old status: {before.status}\nNew status: {after.status}'
if before.activity != after.activity:
title = f'Activity change for {after}'
msg = f'Old activity: {before.activity}\nNew Activity: {after.activity}'
if self.admin_member_update == True:
embed = discord.Embed(title= '**Admin Logs**')
embed.add_field(name=title, value=f'```{msg}```', inline=False)
await channel.send(embed=embed)
```This isn't reading whenever someone updates their status or activity. It works for display name.
**Yes intents and presence are set properly.** Unless there's a random one that's not members and I have to specifically define..
I haven't worked with this listener before so I can't help out here. Maybe wait for someone else or google it
my guess would be intents but you say intents are set properly
@grand anvil listener is the same as bot.event i assume.
I'll try and move the bot out of the cog and use bot.event instead
that shouldn't make a difference as long as you used it in right place which I assume you did
Didnt make a difference
Okay so I did this but the code doesnt work, No error nor does it print
oh.. uh... lemme think
check what are the attributes of before and after in this listener and make sure you're using right names?
async def run_once_when_ready(self):
await bot.wait_until_ready()
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt','r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
await self.bot.loop.create_task(self.run_once_when_ready())
Final code in case you want to see!
there is an extra indentation in last (not sure if I spelt it right but yea)
If I unindent that it says
await self.bot.loop.create_task(self.run_once_when_ready())
^
SyntaxError: 'await' outside function
well I mean you can't call it outside a function. I'd call it in the when_ready listener
im trying to find a way to see if a user has a certain permission in discord.py
but the only thing I can find is @slate swan_permissions which doesn't work for me as it's not for a command
I just want an if statement to see if they have a permission
How to make cog and add commands?
@commands.Cog.listener("on_ready")
async def run_once_when_ready(self):
await bot.wait_until_ready()
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt','r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
can someone tell me why
Ignoring exception in command youtube:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/MathBotDisnake/cogs/youtube.py", line 10, in youtube
i = await ctx.author.voice.channel.create_invite(target_type=TargetType.embedded_application, target_application_id=755600276941176913, max_age=1800)
NameError: name 'TargetType' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'TargetType' is not defined
bot.add_command?
hi hunter... lol
disnake.TargetType......
Thnx bro
Ah, ok. My bad, didn't read their previous message
OH...........
wdym you wanna check it inside a function as a parameter for let's say if statement?
yes exactly
Ignoring exception in command youtube:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/MathBotDisnake/cogs/youtube.py", line 10, in youtube
i = await ctx.author.voice.channel.create_invite(target_type=discord.TargetType.embedded_application, target_application_id=755600276941176913, max_age=1800)
AttributeError: module 'discord' has no attribute 'TargetType'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord' has no attribute 'TargetType'
BTW can anyone here help me make a paginator?
So my API sends some data in the form of a dict, and I want to paginate it in an embed and control it with buttons... I want to show only a maximum of 10-12 entries on one page... Any help?
im just basically making a leaderboard but I dont want moderators to be displayed
Good news: No error
Bad news: It doesnt work
Weird...
so if checking for permissions on the user doesn't wor

Indeed...
Ill just have to check the users id with the mods in the server
!d discord.Invite.TargetType @stone palm
No documentation found for the requested symbol.
The type of target for the voice channel invite.
New in version 2.0.
There
......?
Cool
so target_type=discord.InviteTarget.embedded_application?
InviteTarget?
@commands.Cog.listener()
async def on_ready(self):
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt','r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
```
if this also doesn't work, idk.
NOTE: It won't work with self bots
what is it supposed to be?
I dont want on_ready since it will fire multiple times
I wanted run_once_when_ready
NOTE: Self bots are against ToS
hmm.... then I know what you gotta do
Okay so I updated my code to this to try something
async def run_once_when_ready(self):
await bot.wait_until_ready()
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt','r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
self.asyncio.run((self.run_once_when_ready())
But since this is in a cog I am getting this error
def setup(bot):
bot.add_cog(dailypoll(bot))
Error
def setup(bot):
^
SyntaxError: invalid syntax
ik but doesn't stop people from doing it
bro just put the await self.run_once_when_ready() in __init__ function
and make sure the def setup isn't inside the Cog class
Oh okay
self.asyncio.....?
fuck I copied his code
Also won't work
@slate swan do this updated one
first one made no sense I just blindly copied yours cause I'm in class
U can't run an async function in the init
self.run?
oh right.... bruh
Haha!
bro this is kinda annoying ngl
Lol
@slate swan BTW async def on_ready(self): fires only once in my bot
It fires many times for me sometimes
unless you made a super complex bot which can turn on and off without code stopping, you'll be good with listener
When my bot sends way too many AI Messages haha
oh
Its risky since I will be pinging a role and I dont want it to spam more often than it should
oh
Yea
Don't do it
Instead
Why not make a task and set the count to 1?
And start it at the place where u load your cogs
task.start()

Simple
that's big brain

I don't have a lot of experience with asyncio 
Same
I used tasks only once in my whole bot and used a lot of google for it
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
Thats what I am at
imagine saying you don't know shit about it and then doing that
There (:
Bruh, that's part of the library...
@tasks.loop(count=1)
async def once():
print("Working only once")
once.start()
Ezz
oh wait nvm it was discord library
I thought its asyncio library 💀

discord.py tasks are good. Asyncio tasks are hard
Indeed
So this task will happen each time the bot reboots once?
Indeed
U can do that anywhere, as the task.start() isn't async
Okay time to try that!
(:
whats the equiv of bot.get_channel or bot.get_guild but for member?
member.guild
bot.fetch_member
ah
if you want user, do bot.fetch_user
What's the difference between member and user?
member is with guild context
member is like server member so like you get member's roles and nickname and stuff
and it will return error if the user is not in server
whereas user will give the general info like id and stuff and will work for any user on discord
So anybody in the server (say this python server) is read as a member.
@tasks.loop(count=1)
async def once():
today = datetime.utcnow().strftime("%Y%m%d")
with open('daily_poll.txt', 'r') as file:
if today in daily_poll:
print(today)
else:
print("Cant find it wot?")
No error but it doesnt print 
and once I leave this discord, I'll be regarded as a user (Unless the bot is in a discord I'm in)
yes if you used fetch_member
they'll still be treated as a normal user if you used fetch_user
wait. where is daily_poll variable?
this_file_directory = Path(__file__).parent.resolve()
other_file = this_file_directory / "daily_poll.txt"
with open(other_file, "r+") as file:
daily_poll = [daily_poll.strip().lower() for daily_poll in file.readlines()]
Before the class
Okay
why open daily_poll.txt if u don't use it


