#discord-bots
1 messages · Page 658 of 1
!code @whole tapir
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.
"discord.ext.commands.errors.MissingRequiredArgument: question is a required argument that is missing."?
your missing that arg
you used the command without providing an argument
that was a pain to watch
What do you mean, im sorry Im like brand new to python lol
Even more painful for me to correct it
you command is designed like
!command <question here>
And you did
!command
Could I send my code so you have more reference?
def func(arg):
print(arg)
func("hi")
in this function arg is a positional argument that is needed
output:
hi
can discord bots check the result of a discord search?
Ima warn you now lol my discord is more of a meme bot lol
like how much results were found
https://paste.ofcode.org/q4wxfu4BqMwVJyHniQsKax @slate swan @slate swan
yeah im going to sleep
wait do i add a "func" after?
oof
🚶
oof
Remove the responses from your async def function
And when you use the command ,you need to provide a question
cya okimi
later🚶
How can I make a footer timestamp in an embed that displays the time for the user.
I cant wrap my head around datetime, tried reading the docs and all
Embeds have a timestamp kwarg
timestamp=datetime.datetime.now()
Youll have to import datetime
right but that is based off the local time of my machine right
so its not fully accurate
Dont really know but there is time zone options afaik
could be datetime.utcnow()
thats just based on utc time
if you import it using
what time you want
im looking for a timestamp in the embed that displays the user the time depending on their timezone
not possible
This is not a Modmail thread.
Well In the discord.py discord, ive been told it is
proof
cant place it below I tried
Oh so you cant put it in the footer
damn thats kind of dumb
Ignoring exception in on_command_error
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\admin\Downloads\underdev.py", line 233, in brackets
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a))
File "C:\Python310\lib\site-packages\aiosqlite\core.py", line 184, in execute
cursor = await self._execute(self._conn.execute, sql, parameters)
File "C:\Python310\lib\site-packages\aiosqlite\core.py", line 129, in _execute
return await future
File "C:\Python310\lib\site-packages\aiosqlite\core.py", line 102, in run
result = function()
ValueError: parameters are of unsupported type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\nextcord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\admin\Downloads\underdev.py", line 125, in on_command_error
raise error
File "C:\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 995, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 895, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: parameters are of unsupported type```
@bot.command()
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a))
dataa = await data.fetchall()
print(dataa)
print(data)
dt = list(dataa)
print(dt)
for i in range(1,len(dt),2):
await ctx.send(dt[i],dt[i+1])```
They literally told you how to do that too
Yeah but I dont understand it
so that doesnt rly help me
try
embed = discord.Embed(title='test',timestamp=datetime.datetime.utcnow())
embed.set_footer(text='\u200b')
Basically , if you use timestamp= datetime.datetime.utcnow() it will render (change) according to user's timezones
huh?
:what:
wjat
yea swag is correct , using the timestamp kwarg is better than mentioning time in footer since it won't change
u have to do embed.timestamp = datetime.datetime.utcnow()
That's same
well if u try it in the footer it wont wwork
Why add it as a footer when you have a kwarg for it
but where does the timestamp show if u put it as a kwarg
I dont see why
Where a footer is located
near the footer
thankyou so much, i was overcomplicating it real bad
Ofcourse
is there a way to change the timestamp format?
donno
not the embed timestamps
so it will always be •Today at 12:43 PM
it gets updated automatically
How do you change it to that
Discord does that automatically
huh ? where?
@full valley as said by sarthak
never saw tht
Ah ok, just messes my footer formatting up
its a little messy now
Check your bot's old messages which has timestamps
Don't ask me where
hes asking bout replacint the • with |
i didnt know discord does that too
No he means if he can remove"Today at" in a timestamp
oo
well how do i do tht..
is it possible to do that?
^
same image , different device
thats done by discord and your device
unrelated to your code
Yeah

sadly its a discord limitation xd
i was wondering if this is for server name or id
its for a guild object
Takes any as its a guild object
ahh
😐
I was never here
..
Dude u forgot the comma after a
LIKE IT WAS THAT ERROR!!!! DUDE I AM GONNA KILL MYSELF!!
he lied to me
Hehe
Misinterpreted

ok guys.. this is my las-
I swear discord snowflake server fucking kills my mobile and PC
mute it already
i wasn't able to get in
🙏
so im trying to make my help command look like this command_name/alias but its giving me this error, what do i do?
class HelpPageSource(menus.ListPageSource):
def __init__(self, data, helpcommand):
super().__init__(data, per_page=6)
self.helpcommand = helpcommand
def format_command_help(self, no, command):
signature = '/'.join([str(command), command.aliases])
docs = self.helpcommand.get_command_signature(command)
return f"`{signature}`: {docs}"
async def format_page(self, menu, entries):
page = menu.current_page
max_page = self.get_max_pages()
starting_number = page * self.per_page + 1
iterator = starmap(self.format_command_help, enumerate(entries, start=starting_number))
page_content = "\n".join(iterator)
embed = discord.Embed(
title=f"Help Command",
description=page_content,
color=0xffcccb,
timestamp=datetime.utcnow()
)
embed.set_footer(text=f"{page + 1}/{max_page}")
return embed```
I by mistake clicked it sadly
command.aliases is a list , and join works only with strings
for some reason, this doesn't change the status of my bot (i cut out client.run("token") from the screenshot)
Lmfao
oh. so what do i do?
!intent
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
my man , guildobject being a guild object like ctx.guild or message.guild smthing
Also why not just set the status once instead of changing again and again?
alias for alias in command.aliases
Good thing I passed on him, I literally woke up, didn't wanna ruin my day
Dont you have to do a wait_until_ready? To change presence
Depends
If u r doing it in on_ready then yea
🤲 lol , it sometimes becomes really hard to explain stuff
Hmm
Facts
like this? signature = '/'.join(str(command), (alias for alias in command.aliases)
nu
@bot.command()
@commands.check(checkk)
async def verify(ctx):
await ctx.send('1996, 1981')
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
if msg.content == '1996':
await ctx.send('Correct')
else:
await ctx.send("Correct")
if time3.content == '1981':
await ctx.send('Incorrect')
else:
await ctx.send('No')``` lets say i want multiple questions to be sent, and lets say i have them defined like '`question1 : answer1, question2 : answer2`, how can i randomly select a question, and make the bot `wait_for()` the proper response
the line i sent will give you a list of all aliases , which you can join using .join() for the command signature you would be using something else
oh
@bot.command()
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))
dataa = await data.fetchall()
dt = list(dataa)
await ctx.send(dt)```
```py
[(808940512979451934, 5, 'd'), (726046274624684034, 2, '2j'), (766217463184228353, 4, 'aa'), (854639229802774538, 2, 'h')]```
i want it to send only the ids
docs = self.helpcommand.get_command_signature(command) doesnt this already give you the signature?
and in a format like <@!idhere> vs <@!idhere>
<@!id2here> vs <@!anotheridhere>
how to do it..
[ data[0] for data in dt] will do the job
it will send the full tho wudnt it?
hey i tried this and i didn't see a change in the bot's status?
Can I see?
ofc
!e ```py
dt= [(808940512979451934, 5, 'd'), (726046274624684034, 2, '2j'), (766217463184228353, 4, 'aa'), (854639229802774538, 2, 'h')]
print([data[0] for data in dt])
Sorry, an unexpected error occurred. Please let us know!
ClientResponseError: 500, message='Internal Server Error', url=URL('http://snekbox.default.svc.cluster.local/eval')
wtf
And did u enable them from the discord developer portal?
yeah i had everything enabled from the portal
lmfai
Oh
@bot.command()
@commands.check(checkk)
async def verify(ctx):
await ctx.send('1996, 1981')
def check(m):
return m.author.id == ctx.author.id
time3 = await bot.wait_for('message', check=check)
if time3.content == '1996':
await ctx.send('Correct')
else:
await ctx.send("Correct")
if time3.content == '1981':
await ctx.send('Incorrect')
else:
await ctx.send('No')``` lets say i want multiple questions to be sent, and lets say i have them defined like '`question1 : answer1, question2 : answer2`, how can i randomly select a question, and make the bot `wait_for()` the proper response
here
@slate swan can ya take a look at this?
how do i make like a list of commands in one embed?
like if i were to say !help moderation then the bot would send all of the commands that helps with moderation?
kakashi nice name
have all the mod commands in a single cog
anyone?
and use Cog.commands to get a list of mod commands
following glow's video?
whos glow
ty
glowstick
im not using a video
@commands.check(checkk)
well u defined check uk..
in the next line
and u r using that..
so what will be the use of @commands.check()
sub define what :what:
@static lintel can u add a debug print at the top of the event to see if it's trigerring?
wait what , the bot...
!d discord.ext.commands.Bot.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**...
i forgot the doc thing, but check is an attr of waitfor
i never ever used @commands.check
see
hi eevee
hewwo
anyways, back to it
@bot.command()
@commands.check(checkk)
async def verify(ctx):
await ctx.send('1, 2')
def check(m):
return m.author.id == ctx.author.id
time3 = await bot.wait_for('message', check=check)
if time3.content == '1':
await ctx.send('Correct')
else:
await ctx.send("Correct")
if time3.content == '2':
await ctx.send('Incorrect')
else:
await ctx.send('No')``` lets say i want multiple questions to be sent, and lets say i have them defined like '`question1 : answer1, question2 : answer2`, how can i randomly select a question, and make the bot `wait_for()` the proper response
sad
how would i make docs into the help description for a command?
@client.command(aliases=['rep', 'r'], help="Repeats given text for x amount of times", usage="<amount> <text>")
@commands.cooldown(1, 5, commands.BucketType.user)
async def repeat(ctx, amount: int, content="repeating..."):
for i in range(amount):
await ctx.send(content)```
like this?
try using a dictionary to send the questions and check the answers
Yea
i also want this;s answer..
are u skidripping my source :|
how do u check the answer
!d random.choice
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
nah i am also making a quiz game
😐 It's damn easy to make a quiz game istg
just add custom indices to every dictionry in a list and use those to check the answers
thats the easiest way I can provide ,-,
can someone help
description="hi"
but its help :/
Smh this is the basic logic
🤷♂️
???
reply to this
u can also help if u want
thats not what i asked you to do...
read it again
Cz yr logic is wrong
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))
dataa = await data.fetchall()
dt = list(dataa)
print(data[0] for data in dt)```?
answer is a string but bet is an int
this is what u said..?
@slate swan
^^^
Well it depends...
What's bet here?
They are coins I am sure
Yea
And u r comparing it to heads/tails
Which will always return false and execute the else
Understand?
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))
dataa = await data.fetchall()
dt = list(dataa)
await ctx.send(dt[0])``` how do i get to display only the ids cuz this displays the whole row but i only want the 1st item
Uhhhh, u aren't able to understand
is there a way to make the bot remove the reaction right after when a user presses that reaction? https://mystb.in/MajorityConsentAmended.python
its a boolean.....
U r comparing the number of coins betted to the result of the coin. Suppose u input !coinflip heads 10, then whats the if statement is doing is if 10 == answer where answer is the random.choice
^^
U r overwriting the choices variable in 5th line. Fix that, and after that compare choices to answer
can someone help
Yea
Wait do one thing
The choices variable in the function. Change it to choice
Then compare choice and answer
Rest everything is correct
how can i make the bot reply like this?
Well in the choices = (...) Line, u r overwriting the user input which makes no sense
better discord ey
Slash Commands.
aight thanks
await ctx.reply("")
?
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.
ctx.reply
true but slash commands are cooler
They are broke
anyone?
nah idk sql
its not sql rn
message.channel.reply
check if that exists
idk I just removed anything but the 1st item lol
bre
message.reply works
You don't reply to a channel kek
Huh?
why is it ctx.channel.send
you could use ctx.send or does that also have no response too
ctx.send works
because i could be misunderstanding here
and if that doesn't work, use ctx.reply
and idk what will work if ctx.send and ctx.reply don't work ¯_(ツ)_/¯
have no idea but just check ¯_(ツ)_/¯
if ctx.send or ctx.reply works
works or no?
?
@maiden fable ?
ah wrong
u do answer = random.choice() and then compare choice and answer
.fetchone() should work else idk I don't work with SQL sorry
choice is what the random module chose im pretty sure
yea
Try adding debug print statements
print statement in every other line to see which line is working
!paste thanks but using a paste would be appericiated
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.pythondiscord.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.
Is there a reason why you're doing random.choice("Heads", "Tails")? `random.choice should be passed a sequence
E.g random.choice(["Heads", "Tails"])
yes that creates a list
Sorry, an unexpected error occurred. Please let us know!
ClientResponseError: 500, message='Internal Server Error', url=URL('http://snekbox.default.svc.cluster.local/eval')
Ok then snekbox
what packages do y'all use to like, make discord buttons
damn
discord.py forks
or you can use discord.py 2.0 version
hmmm alr
am i going to get help
?
prob not
its not related to sqlite
i want to choose the 1st item from a list and send it
thats literally sql tho
oh
bru cant you just do something like this
!e mylist [1, 2, 3]
print(mylist[0])
Sorry, an unexpected error occurred. Please let us know!
ClientResponseError: 500, message='Internal Server Error', url=URL('http://snekbox.default.svc.cluster.local/eval')
ugh
not like tht
[(808940512979451934, 5, 'd'), (726046274624684034, 2, '2j'), (766217463184228353, 4, 'aa'), (854639229802774538, 2, 'h')] i got this result from sql in list
i understand basic sql
i want to only get the ids from this list
have no idea how to do that
It's a list of tuples, so just index it 
kraots the pro of the proest
umm?
index it
Do you not know how to use lists and tuples 😐
(1,2,3) tuple
[1,2,3] list
Yes, that's what a tuple is and that's what a list is
You can use map and a lambda
But do you know how to use them
index it?
list.pop
list.append
complicated......
This guy doesn't even know how to index, i think that's a bit too much for him 💀
🤔
i didnt learn it in 5 python courses
You could use a for-loop and access the first index then
Or use a list comp to do the same thing
lst = [1, 2]
first_elem = lst[0]
# tuples work the same
how to make a command that makes my bot leave all servers with under 5 members
oof ik this
WOW
i didnt know this is indexing
It's basic python, and I never learnt out of any course lol
i didnt know the name but ik this
i knew this
but didnt know what its called...
Check if the members are less than 5, if they are then use Guild.leave
anyways if i do that it returns the 1st tuple
!d discord.Guild.leave
await leave()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Leaves the guild.
Note
You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
..thts why came here
How to do that?
Yes, with a for loop you can loop through the list
!d discord.Guild.member_count
property member_count: int```
Returns the true member count regardless of it being loaded fully or not.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
I'm not gonna spoonfeed, gave you the logic, gave you the docs to everything you need, the rest is up2u
for i in dt:
print(dt[0])
👍
👁️👄👁️
😐
wtf
You are laughing on your own mistake ngl
yo 💀
kek
you mean guilded
the new discord alternative which i hate
YO WHAT IS GUILD?
Ok I am going bye
guild = ctx.guild

and later that day he was never seen again :p
DUDE can you stop??
was a joke
:pogbruh:
https://paste.pythondiscord.com/rekipeluji.py
i need the verify command to work and no other ones, only for this specific channel, whilst deleting any other messages sent in the verify channel using the verify command
how do you import discord_slash.utils.manage_components without an undefined module error
only discord_slash.model works to import but what about the message above me
this guy asked this in the discord.py server lol
he was evading a ban
nuke bots = >:(
nuking scam discord servers = >:)
jk nuke is against discord tos but back to discord bots
@client.commands()
async def servers(self, ctx):
activeservers = client.guilds
for guild in activeservers:
await ctx.send(guild.name)
print(guild.name)
await ctx.send(guild.member_count)
isn't this sorta not allowed
Why wouldn't it
Tryna remove it from servers under 5 members because wasn't able to get verified
idk privacy?
What privacy
It's just the guild's name in which the bot is in
And the member count
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))
dataa = await data.fetchall()
dt = list(dataa)
for i in dt[0]:
await ctx.send(i)``` well now how do i iterate thro like this for the whole list.
it sends the id for dt[0]
idk
now do i have to repeat that for dt[1] dt[2]
@client.commands()
async def servers(self, ctx):
activeservers = client.guilds
for guild in activeservers:
await ctx.send(guild.name)
print(guild.name),(guild.member_count)
feel free to call me stupid, as long as ill get this working ill be happy 
how do i do that at once
Already told you how
And you still did it wrong
i did for for-loop
And you did it wrong, completely the opposite of what I said
this sends the 1st tuple
i want the 1st value of the list from the 1st tuple
and like that for every thn in th e list
You're looping over every element in the list and named that variable i so why are you indexing the list that you're already iterating over
As the docs say, you need member intents for member_count to return a number
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
i wud send numbers
as 1,2
?
Is it possible to enable that in dev portal or do i need to get it verified

If your bot isn't verified you can enable it
If your bot is verified you need to apply for member intents
So I just saw a repo of mine which was dead since 5 months had a PR open from about 25 days ago 😐
thats me man
i got banned because someone got mad at people who had default pfps and i defended the person with no pfp, and got banned for provoking arguments
very weird situation
i got muted because well I was contradicting a mod
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = await (await client.fetch_channel(885464532959526913)).send(f'Welcome to server **{member.mention}**.')
role = discord.utils.get(member.guild.roles, name='Unverified')
roles_list = ["•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•", "•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)
await member.add_roles(role)
print(f"{member.name} has joined the server")```
very weird mod system there
Hi the auto role Unverified the bot is not assigning it to the member
can someone help me
why using fetch and not get
I got server intents and presence intents on is there something im msising
members intent
Did you enable it on your bot as well?

cuz role is now the items in your list?
@bot.command()
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT * FROM users ORDER BY RANDOM() LIMIT ?;",(a,))
dataa = await data.fetchall()
dt = list(dataa)
for i in dt:
await ctx.send(f"<@!{i[0]}>")``` now how do i do like 2 values shud be sent in one msg...
cuz all values are stored together
??
Ohh i should add that to the list then?
ig
Wdym by "together"
in pairs
ok
Again, what is that supposed to mean
Send an example where it's sending the way you want
data[0] for data in dt , gives u a list of ids ,, use it according to your needs
I mean, you could avoid this whole problem entirely by doing a SQL query that actually make sense if you only want the IDs
f"{1stvalue} vs {2ndvalue}
^
E.g ```sql
SELECT id FROM users ORDER BY RANDOM() LIMIT ?;
Bru..
Add a count and a list, increment it by one with each loop and append the id to the list, check if the count is equal to 2, if it is, then reset the count back to 0 and send the message while also resetting the list to an empty one
nope nothing is happening
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = await (await client.fetch_channel(885464532959526913)).send(f'Welcome to server **{member.mention}**.')
roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)
print(f"{member.name} has joined the server")
indent await member.add_roles(role) in the for loop
@bot.command()
async def brackets(ctx,p:int):
a = int(p*2)
data = await bot.db.execute("SELECT uid FROM users ORDER BY RANDOM() LIMIT ?;",(a,))
dataa = await data.fetchall()
dt = list(dataa)
for i in dt:
await ctx.send(f"<@!{i[0]}>")
l = list(i[0])
for t in l:
await ctx.send(f"{t[0]} vs {t[0+1]}") ```?
i didnt understand.. be more precise plz
Make an int variable and a new empty list variable, when you loop just increment that variable by 1 while appending to the empty list, check with an if statement if it's equal to 2, if it is then send the message, then reset the int variable back to 0, and set the new list back to an empty one
Can't be more precise than that
Actually you don't even need that int variable, just the list to which you append and check if the length of the list is equal to 2, and then if it is, send the message and empty the list
It's really just basic python tbh
Which is why I won't help any further with this 👍
basic embeds
Can someone help?
i got it thx
Whats the await thing to send an embed?
await ctx.send(embed=Myembed)
its not ctx
learn dpy
Its await member.send(embed=Myembed)
Am very familiar with dpy
idts
a = []
for i in dt:
await ctx.send(f"<@!{i[0]}>")
f=i[0]
a.append(f)
s = 1
await ctx.send(f"{a[0]} vs {a}")
a=+s``` @slate swan were u saying smthn like this?
no one will help you make that
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
That's an embed that has some files a thumbnail footer and a description and a title
You can do all that by constructing the embed
Creating fields titles footers and passing the required values in em
thats to dm the member 
*by
and that would raise an error if the member has their dms off
or you are not in mutual guilds with them
Thanks
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome"),
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"),
await member.send(embed=Myembed)```
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 53, in on_member_join
await member.send(embed=Myembed)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\dpy_overrides.py", line 350, in send_override
return await send(channel, *args, **kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\dpy_overrides.py", line 244, in send
embeds = [embed.to_dict()]
AttributeError: 'tuple' object has no attribute 'to_dict'```
await message.channel.send(content=None, embed=embedname)
no lol
its the same thing
uh, maybe you could loop the dict with highest values?
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome")
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)")
await ctx.send(embed=Myembed)```
How do i let it `await` to the channel?
also not really related to dpy
channel.send? or wdym
yes channel.send
just do that and should be okay
ok question is there an easier way to avoid restarting the bot everytime?
and make the new changes
code
you have to restart it everytime afaik, otherwise it wont get changes
not from me as I have no idea how to do that
maybe #python-discussion knows
didn't do anything but you welcome 🤷
I just moved my bot across to another guild, and a check is failing even though it works fine in the original guild.
Any ideas?
(A check for a command)
what check is failing?
could you provide a bit more information?
# Checks command issuer not already in a game dictionary
def is_issuer_in_game(ctx):
piglist = []
for x in games.values():
for _ in x:
piglist.append(_)
print(piglist)
print(games.values())
return ctx.author.id not in piglist
# !q command -> Puts players into queue
@bot.command(name="queue", aliases=["q"], description="Join the queue")
@commands.check(is_issuer_in_game)
@commands.has_any_role(verified_role, 908784013181878342)
async def queue(ctx):
# Handling error if player is already in queue
@queue.error
async def queue_error(ctx, error):
if isinstance(error, commands.CheckFailure):
embed = discord.Embed(
title=f"**You are already in a game**", 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)
Top is check, bottom is error handler, middle is command.
I printed the piglist and games.values() as shown above in the check, and the list and dict values were empty
[]
dict_values([])
I try the command in old guild and it works fine, try it in this one and get hit with the error handler
Could you just please let me know what the codes are for account creation of the member and the mention of the member who invited them?
if that make sense
member.created_at returns a when it was created, by viewingaudit log you get the invited user
any ideas or no 
no not really
.
I did too earlier
@bot.command(aliases=['the_worst_command_ever'])
async def h(ctx, member: discord.Member):
if member not in ctx.guild.members:
await ctx.send("amongus")
else:
await ctx.send(f"{member}")
would this work? 🤔
should work, looks good to me
so i accidentally made a error handler inside of a command
heyu
well some sort of error handler, more likely a normal if statement
hmm
but ye it could be a error handler as well
@slate swan you are making a music bot?
ya
!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)
?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: create_stage_channel() got an unexpected keyword argument 'bitrate'
code?
is that entered in the embed field type?
field value, yes
g=ctx.guild
for cate in g.categories:
x = await g.create_category(f"{cate.name}")
for chann in cate.channels:
if isinstance(chann, discord.VoiceChannel):
await x.create_voice_channel(f"{chann}", bitrate=chann.bitrate, rtc_region=chann.rtc_region, user_limit=chann.user_limit)
if isinstance(chann, discord.StageChannel):
await x.create_stage_channel(f"{chann}", bitrate=chann.bitrate, user_limit=chann.user_limit, rtc_region=chann.rtc_region, topic=chann.topic, position=chann.position)
if isinstance(chann, discord.TextChannel):
await x.create_text_channel(f"{chann}", nsfw=chann.is_nsfw(), topic=chann.topic, slowmode_delay=chann.slowmode_delay)```
Please don't mind the indentation
unreadable code
!paste helps with indent stuff
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.pythondiscord.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.
most of time*
fix?
I don't even understand what you are doing (no need to explain as I won't understand it)
it doesn't have bitrate arg
U r creating double categories?
yesh
Why
just i want to try
?
...
await create_voice_channel(name, *, reason=None, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`VoiceChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel "discord.VoiceChannel") instead.
i am eating lunch this is the code
error above
!d discord.Guild.create_stage_channel it doesn't have a bitrate kwarg
await create_stage_channel(name, *, topic, position=..., overwrites=..., category=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`StageChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.StageChannel "discord.StageChannel") instead.
New in version 1.7.
stage
Oh I got the answer to my question
How would you make a command like !invite 1 that you would generate a 1 invite link
@slate swan
Invite link to?
!d discord.TextChannel.create_invite
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.
Random ping
!ban @boreal ravine random pings
@junior verge 
Imagine
:kek:
I must now ban you both from nextcord for random pings 😔 /s
^^
sad
import discord
from discord.ext import commands
import datetime
class Invite(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(pass_context = True)
async def invite(ctx, userToInvite):
inviteLinq = await ctx.create_invite(destination = ctx.message.channel, xkcd = True, max_uses = 1)
await ctx.send_message(userToInvite, inviteLinq)
def setup(client):
client.add_cog(Invite(client))
``` won't this work
What should it be though
create_invite
ctx.send?
isnt even a thing in commands.Context
!d discord.Member.send if you mean sending to a member
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**.
I dont know I was just looking for something and seeing if it works man
I have no clue on how to make what I want
but you don't just go around creating custom attributes and hope it works
well, explain what you wanna do
Yeah alright
So I want to make a command for people that do not have invite permissions that would be .invite and it would generate a 1 use invite link, also in a embed etc but that won't matter at first
invite link to? your bot? a channel? an activity?
To the server you are typing the command in
ah
!d discord.TextChannel.create_invite please don't use the class name, use an instance of it, Context.channel you can make everything empty and just call the function without any kwargs iirc
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.
what would this do
Create an invite
@client.command(pass_context=True)
async def invite(ctx, time_in_seconds,uses):
invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=uses,max_age=time_in_seconds)
await ctx.send(invitelink)
``` I got this now this is kinda what I want but not really
to a channel (the server)
Why are you using the class altogether
What's wrong with it?
nothing, is it is nvmuses/time_in_seconds defined?
that should work ig, btw remove pass_context lol
okay
Slash commands/Interactions
ah interactions
yes
but how would I make the command so it always would make a 1 use link for 1 week
read the docs, change uses to 1 and change the max_age into a week (seconds)
@tawdry perch rip.
indeed
uhm like this?
@client.command()
async def invite(ctx, time_in_seconds,uses):
invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
await ctx.reply(invitelink)
I absolutele did not join to view the server
yes
also remove time_in_seconds/uses lol, kinda useless rn
kinda offensive, "troll"
lol
Yeah k
And got absolutely flexed on
:kek:
moves to alt account
import discord
from discord.ext import commands
import datetime
print('invite')
class Invite(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def invite(ctx):
invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
await ctx.reply(invitelink)
print('invite2')
def setup(client):
client.add_cog(Invite(client))
``` why doesn't the cog work
you need self
its a class
or you didnt load the cog
Yeah no I forgot self
I'm aware this isn't directly linked to a discord bot but I'm trying to install Disnake to code a bot, yeah?
I end up getting an error when running pip install disnake. My terminal is Termux in mobile, here's the error:
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.
I've tried resetting all of Termux' data, that didn't work
I tried on multiple connections, none of them work
nvm
did you just copy out the discord.abc.GuildChannel?
What?
@commands.command()
@has_permissions(manage_messages=True)
async def invite(self, ctx):
invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
await ctx.reply(invitelink)
print('invite2')
``` no I am trying to get the has permissions work
it should not work with discord.abc.GuildChannel afaik
import has_permissions, CheckFailure py right
it should
really?
it works already mate
I did not know that ;-;
how does it not work?
Just gives a error
show
@commands.command()
@has_permissions(manage_messages=True)
async def invite(self, ctx):
invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
await ctx.reply(invitelink)
print('invite2')
@invite.error
async def invite_error(error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send("You don't have permission to do that!")
just do commands.has_permissions?
what do you mean
import it from the commands extension discord/ext/commands
on the same line you mean
import discord
from discord.ext import commands import has_permissions, CheckFailure
import datetime
not like that right
no, ```py
from discord.ext.commands import ...
try again now
@client.command()
@commands.is_owner()
async def leaveguild(ctx, *, guild: discord.Guild):
await guild.leave()
await ctx.send(f"I've left {guild.name}!")
says command leaveguild isn't found
discord.ext.commands.errors.CommandNotFound: Command "leaveguild" is not found
is this command in a class?
whats this
my error command is not working
@invite.error
async def invite_error(error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send("You don't have permission to do that!")
add self if its in a class
Help
ofc....
hmm. show full file ig
istg it existed, brb
just commands.has_permissions
how do i define missing permissions
whut?
any idea
!d discord.ext.commands.bot_has_permissions
@discord.ext.commands.bot_has_permissions(**perms)```
Similar to [`has_permissions()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_permissions "discord.ext.commands.has_permissions") except checks if the bot itself has the permissions listed.
This check raises a special exception, [`BotMissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BotMissingPermissions "discord.ext.commands.BotMissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
@unkempt jewel <==
can i dm u i dont feel safe sending the code here
!d discord.ext.commands.MissingPermissions <=
exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
sure I guess
now i got this
import discord
from discord.ext import commands
from discord.ext.commands import MissingPermissions import has_permissions, CheckFailure
import datetime
``` how do I list this correctly
List? wym by that
whats l?
correct order
L?
the variable l
for what?
yes l/I/i whatever
i dont have that variable bruh
you way of importing is wrong py from x import y , z is how you do it
MODERATION
@client.command()
@commands.has_permissions(manage_messages = True)
async def clear(ctx, amount = int):
await ctx.channel.purge(limit = amount)
amount: int
aaahhh thanks mate
by setting amount to int you're setting it to the type of int
rather than hinting that it should be one
theres a difference between setting something and changing its type
Out of curiosity, can bot's share screen?
no
would be a legality nightmare 
!channel 2
async def on_raw_reaction_add(payload: discord.RawReactionActionEvent):
With this function, how can I check if a user has specific roles. E.G if user has role named "muted", return true
!d discord.RawReactionActionEvent
class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
what's the diff between on_raw events and the normal ones?
!d discord.RawReactionActionEvent.user_id
The user ID who added the reaction or whose reaction was removed.
Use this (:
on_raw events trigger everytime whereas other ones trigger only if the message is there in the cache
AttributeError: 'Message' object has no attribute 'payload'```
anyone got a solution?
memberid = await channel.fetch_message(payload.message_id)
await memberid.payload.send(f"Your reputation was deleted, it could be for the following reasons: 1. 2. 3. To prevent this from happening again, make sure your reputation is VALID")
```
message.channel.send*
ah
Did u notice there's a difference in params of both of those?
yeah
reaction, user, payload ig
@commands.command()
@has_permissions(manage_messages=True)
async def invite(self, ctx):
invitelink = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1,max_age=604800)
embed=discord.Embed(title="Your invite link!",description=f"(invitelink)", color=0xFF5733)
await ctx.reply(embed=embed)
print('invite2')
``` how would I make it so it sends the (invitelink) in the desc of the embed
Not sounding like a good idea
use {} around invitelink
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
# !substitute command -> Subs a player in if a q has popped
@bot.command(name="substitute", aliases=["sub"], description="Sub a player in")
@commands.has_any_role(staff_role, "Developer")
async def substitute(ctx, thegameid, oldplayer: discord.User, newplayer: discord.User):
if ctx.channel.id in allowed_channels:
try:
gameid = int(thegameid)
index = games[gameid].index(oldplayer.id)
games[gameid][index] = newplayer.id
if oldplayer.id in team1_ids[gameid]:
print(team1_ids)
index1 = team1_ids[gameid].index(oldplayer.id)
team1_ids[gameid][index1] = newplayer.id
embed = discord.Embed(
description=f"**{newplayer.mention} has been swapped in for {oldplayer.mention} on team 1**",
color=0x00FF00)
embed.set_footer(text=f"Authorised by {ctx.author.name} | CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
print(team1_ids)
if oldplayer.id in team2_ids[gameid]:
print(team2_ids)
index2 = team1_ids[gameid].index(oldplayer.id)
team2_ids[gameid][index2] = newplayer.id
embed = discord.Embed(
description=f"**{newplayer.mention} has been swapped in for {oldplayer.mention} on team 2**",
color=0x00FF00)
embed.set_footer(text=f"Authorised by {ctx.author.name} | CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
print(team2_ids)
else:
await ctx.message.add_reaction('❌')
await ctx.channel.send(embed=embed)
except Exception:
print(traceback.format_exc())
ctx.message.add_reaction('❌')
``` How come its adding a cross and also sending the embed?
Anyone in the snowgiving server?
In the what?
This but it's full i'm curious about the new features
i joined and my client crashlooped 
Or is it just the activity stuff from Discord
also the server is now full
prob
yeah
Yeah pretty sure they putted a cap on it.
What does it got?
where can I get invite?
800k members ;-;
Pretty sure it caused this spike lol
Happens every time i click on it. My discord crashes
for i in range(0,len(Json_Items)): #It doesn't exist
for x in Json_Items[i]:
if int(x) == int(member.id):
print(x)
del Json_Items[i][x]
json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1)
return
Anyone know how to fix this leaving:
[
{}
]
in the JSON
I wanna know what is the experimental stuff.
Ah well the VC games feature is now implemented there for one
O
The server is too laggy i cant scroll down on channels or click them
Ah well that has been out a long time (for devs coding bots)
I think the VC games are pretty great.
Lmfao discord is like: Welp everyone adding unadded features even before we added them, so let's stop verifying bots with these features
Those are some new games for VC never seen those.
Haha you still can use it you just need to make the raw api call yourself.
Discord isn't verifying bots having VC Games anymore
And have the game id.
still works 😛
Never said they stopped working haha
I am just saying, suppose my bot HunAI has that feature... Then discord would deny the verification
Ohh in that sense.
Yea
Well i think that's fair since they allowed Discord bot devs to showcase it not release it beforehand.
disnakeeee :)
So rn, there is no way to save the Invite object, right?
I meant dpy implementations*
wdym save?
In the cache?
Like, saving those to a db for future use
Instead of calling the API again and again
Well i don't see why not..?
Like saving guild.invites
How can u save the invite object?
What db are you using?
Because i don't think any sql based db allows to store objects only datetime.
That's the issue. U can't save the object to a simple db that we use in day to day coding
Yeah that makes sense, how would the DB treat them?
What do you need to store from that object?
But, if discord.py made the JSON received from the API, an instance variable, then we could just have got the raw JSON with invite.data and store the dict, and manually convert it to an Invite object, but in here https://github.com/DisnakeDev/disnake/blob/master/disnake/invite.py#L352-L370 the lib is directly getting the keys
You could just add another table and inner join it using the guild id.
?
Fetch that and cache the db result by remaking the object.
My question is, how to "store" the discord.Invite object to the db
Yea that's what I am saying. Manually parsing the to make it an invite object
It will become just like getting the JSON from the API and then parsing it
Hey, so I tried making a restart command for my bot but it doesn't seem to start back up after
Here's what I got:
https://stackoverflow.com/questions/63550695/how-to-restart-a-discord-py-bot-using-commands#comment122039112_63551192
I have a discord bot in discord.py, and want to make a restart command using commands.
I saw:
await login(token, *, bot=True)
on the docs, but that doesnt work, and it marks "login" as u...
Just we are fetching it from the DB instead of the API
Yeah indeed but without the rate limiting and your db being 100x faster.
ok maby 10x
Won't work directly since when u do logout() it will stop the bot iirc. But u can try the answer a person gave
This is pretty old code also you got an answer, did you see it?
Well I am not talking about speed here... Well yea, speed will also increase, but I am just saying that this way we can reduce API Calls and prevent getting ratelimited
What exactly are you trying to reset or reload?
restart the bot, pretty much go offline then back online ( so it has new code )
tired of closing and running it agin
I think you can use cogs for that.
!d discord.ext.commands.Bot.reload_extension
reload_extension(name, *, package=None)```
Atomically reloads an extension.
This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
But why..?
¯_(ツ)_/¯
.
I'd still refer you to cogs, or tell us exactly what it is you are trying to reload.
the entire bot
Like a command or event, or the actual Bot source.
Bruh
Also u know... Restarting bot too much isn't recommended
All your cache would be destroyed if u restart it
oh
It's just like u manually starting and stopping it
That's why we are saying to use cogs
What are the benefits of using the cache though
Henche why i'm asking if it is really necessary yeah i know a way and hunter prob does too but why..?
if you want it to auto update then the best way would be something like kubernetes deployment using github actions
You can use an external process manager for it but yeah ^
Less API calls etc. etc
else something like pm2 with an update script
Cache is RAM
what are the pros of using discord.ext.commands.AutoShardedBot?
The data is stored in the RAM (memory), so faster exchange
As long as ur bot ain't in more than 1.5k servers don't use it
ah
If your bot is very large (in terms of guilds) then it will distribute the load across multiple bots.
Multiple processes*
You don't have to make unnecessary api calls every time you want to get some data
okay
*shards
autoshardedbot doesnt us multiple processes
O
it just opens multiple websockets on the same process
Sadly
Ah
oh nice
thank you!
What's sad in it 
So like, it connects more than one time to the discord websocket?
unless you have like 10k servers you probably dont need to be on more than one process tbh
What's the advantage of that tho?
maybe if you're handling presence updates
multiple websocket connections are made so less load compared to single
O
Does autosharded increase the ratelimit amount in terms of when you are getting rate limited at x amount of calls?
No
"It can't change ratelimits"
What if you'd connect each different socket to it's own IP address.
what would that change?
Well ratelimit is IP based no?
I think they meant that there's no "single ratelimit across each connection", each connection has its own dynamic ratelimit
Okay so if i got a bot that is in 500k guilds that would make a lot more api calls than a bot that has 1k bots. Does Discord look at the user & guild count? (Just curious
)
Also the global rate limit -> https://discordapp.com/channels/267624335836053506/463035241142026251/748925092637048893
I wanna get back my scripts from heroku. What should I do?
Contact Heroku.
My scripts are deleted. I just want a copy of them
How can I download them
i know this is possible is discord.js but is making the activity change constantly possible to do in discord.py as well? if so how?
Pretty sure if Heroku deleted them it's gone.
We don't help abuse the API here 👀
Didn't know it had anything to do with api
i saw a bot changing it and thought it looked cool
Well each time you change it you make an API call. You can do it is Python as well but put an interval on it, the API isn't meant to change activity very quick.
Discord has also banned various users who did this with their user token.
From my device I mean. Not the heroku
Elaborate?
???
the bot changes its status every 1-3 seconds and these are the statuses
Listening to for /help
Competing in mario 64
watching SomeOrdinaryGamers
playing with a flamethrower
Elaborate meaning explain what you mean/ give me more details on what you mean.

Yeah and that is the definition of API abuse. We don't condone this here.
Guys big problem lol
what if i made it do it once a minute instead?

I just installed node and npm
sudo apt-get install npm
sudo apt-get install nodejs
how can I delete them now
We'd prob say 30 min to an hour

ah that's a bit too long, no point then
Might aswell reinstall the OS now.
this is a vps
SHould I reinstall the server?

