#discord-bots
1 messages · Page 719 of 1
Send the message before the loop.
So it doesn’t continuously send messages.
Just send the one and edit it in the while.
How can i get the invite link which the bot is in
@bot.command()
@commands.cooldown(1,2,commands.BucketType.channel)
@commands.has_guild_permissions(manage_messages=True)
async def purge(ctx, num):
amount = int(num)
if not amount:
return
await asyncio.wait(1)
ctx.channel.purge(amount=amount)
why it doesn't purge?
You need to await it, like your error in the cmd says
What do you mean?
Guys, how can I connect a Discord Bot with Roblox API, in the way that Bot connects when the product from the game has been purchased and adds the value of that product to the user's variable.
So basically, user buys for example product worth 10 robuxs, and then the bot adds 10 to his variable.
If possible, with -30%.
Can anybody help me, please?
ohhh right
The bot is in one server how can i make the bot print the invite link of that server
This is considered as backdooring, and is against Discord's Developer Policy
Can you, help me, please?
backdooring?
and now why it's just waiting?
@bot.command()
@commands.cooldown(1,2,commands.BucketType.channel)
@commands.has_guild_permissions(manage_messages=True)
async def purge(ctx, num):
amount = int(num)
if not amount:
print(amount)
return
print("Waiting")
await asyncio.wait(1)
print("Purging")
await ctx.channel.purge(amount=amount)
print("Purged")
!d discord.Guild.invites
await invites()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns a list of all active instant invites from the guild.
You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to get this information.
Then you'd need to take a random invite from the list.
Then to get the guild with the ID you can use get_guild or fetch_guild
its asyncio.sleep if you want it to stop for the mentioned seconds
!d asyncio.wait
coroutine asyncio.wait(aws, *, timeout=None, return_when=ALL_COMPLETED)```
Run [awaitable objects](https://docs.python.org/3/library/asyncio-task.html#asyncio-awaitables) in the *aws* iterable concurrently and block until the condition specified by *return\_when*.
The *aws* iterable must not be empty.
Returns two sets of Tasks/Futures: `(done, pending)`.
Usage:
```py
done, pending = await asyncio.wait(aws)
``` *timeout* (a float or int), if specified, can be used to control the maximum number of seconds to wait before returning...
don't i have to give any args
ohhh it was sleep yeah
No, nothing
As the description says
Returns a list of all active instant invites from the guild.
Since it's a coroutine you will need to await it
Guys, how can I connect a Discord Bot with Roblox API, in the way that Bot connects when the product from the game has been purchased and adds the value of that product to the user's variable.
So basically, user buys for example product worth 10 robuxs, and then the bot adds 10 to his variable.
If possible, with -30%.
Can anybody help me, please?
Then you get a list of discord.Invite objects
@bot.command()
@commands.cooldown(1,2,commands.BucketType.channel)
@commands.has_guild_permissions(manage_messages=True)
async def purge(ctx, num):
amount = int(num)
if not amount:
print(amount)
return
await asyncio.sleep(0.01)
print("B")
await ctx.channel.purge(amount=amount)
print("C")
it's still stuck purging 🥺
And you can use multiple attributes or methods on a random element.
is 0.01 second even notice-able?
what are you trying to do though?
purge
It's not amount
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
It's limit
hey so i have this code for a rhyme command here:
@bot.command()
@commands.guild_only()
@commands.cooldown(1, 3, BucketType.default)
async def rhyme(ctx, *, word):
try:
def check(r: disnake.Reaction, u: Union[disnake.Member, disnake.User]):
return (
u.id == ctx.author.id
and r.message.channel.id == ctx.channel.id
and str(r.emoji) in ["🔄"]
)
async with aiohttp.ClientSession() as session:
newword = quote_plus(word)
url = await session.get(f"https://api.datamuse.com/words?rel_rhy={newword}")
urlJSON = await url.json()
rdn = random.choice(urlJSON).get("word")
success = await ctx.reply(f"Word: {word}\nWhat rhymes: {rdn}")
await success.add_reaction("🔄")
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=30.0,
)
except IndexError as ie:
await ctx.reply(f"There are no words rhyming with {word} :(")
except asyncio.TimeoutError:
pass
else:
newWord = random.choice(urlJSON).get("word")
if str(event[0].emoji) == "🔄" and not event[1].bot:
await success.edit(content=f"Word: {word}\nWhat rhymes: {newWord}")
else:
pass
and the bot.wait_for only listens to 1 reaction, is there a way to make it listen to all reactions until the timeout is triggered
No there is no way using wait_for
It only waits for the first event
Only way would be to use the event made for it
"using wait_for"
!d discord.on_raw_reaction_add
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
well ofc you can't use wait_for to loop it but is there any other way to listen all the reactions until timeout
wait i misunderstood your statement
but can't you just use while or something?
What is the input of member you give when executing the command?
local variable 'emoji' defined in enclosing scope on line 60 referenced before assignment
@bot.command(name='mine')
@commands.cooldown(1, 60, commands.BucketType.user)
async def mine(ctx):
await emoji(ctx)
num1 = random.randint(0, 100)
num2 = random.randint(0, 100)
lootcount = 101
loottype = None
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.
And what is its purpose?
global var
Just make a file for your emotes
...
why this error
it works with other global var
but not this one
it works?
Why would you need to make such a messy and pretty much useless function?
No
the stupid scoping error will come out again
i tried that
Then you can use emotes.variable
trust me it wont work
...
Don't make a function
my variable
bed = db[userid + 'bed']
it will tell userid undefined
:/
just tell me how to fix that pls ;-;
dun complicate the stuff
@slate swan
How do I make multiple clickable links in an embed response?
As your code says
You should give an argument such as Something#1234
I would try to understand the code before just copying it
Guys, how can I connect a discord bot with a roblox game, so whenever buys a product in a game it pops a message in the discord server with his user & amout he purchased?
or if its possible, that it adds that amout on that user's balance
Please somebody help
I want to create something like this, but idk what to look up in the documentation.
how do I make it so discord bot notifies whenever someone buys a product in roblox game and if possibly, it adds that amout on user's balance
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 886, in invoke
await self.prepare(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 820, in prepare
await self._parse_arguments(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 726, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 578, in transform
return await run_converters(ctx, converter, argument, param) # type: ignore
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\converter.py", line 1182, in run_converters
return await _actual_conversion(ctx, converter, argument, param)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\converter.py", line 1076, in _actual_conversion
return await converter().convert(ctx, argument)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\converter.py", line 395, in convert
raise ChannelNotFound(channel_id)
discord.ext.commands.errors.ChannelNotFound: Channel "None" not found.
``````py
@commands.command()
async def mock(self, ctx, message: discord.Message):
embed = discord.Embed(color=ctx.author.color, timestamp=datetime.datetime.now())
embed.set_author(
name=str(message.author),
icon_url=message.author.display_avatar.url
)
await ctx.send(embed=embed)
await ctx.message.delete()
not sure why it keeps raising ChannelNotFound
How do I make python ignore this and treat it as a string?
It's blue like it's a variable
use a \ before it
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!paste
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.
line 693 error
local variable 'emoji' defined in enclosing scope on line 60 referenced before assignment
i dont understand why is it an error
:/
it doesnt have a value
or you referenced it before assignment ofc
you didnt reference it before assignment so probably it doesnt have a value
how do i make it so the bot listens to every reaction and not just one, this is my code:
@bot.command()
@commands.guild_only()
@commands.cooldown(1, 3, BucketType.default)
async def rhyme(ctx, *, word):
try:
def check(r: disnake.Reaction, u: Union[disnake.Member, disnake.User]):
return (
u.id == ctx.author.id
and r.message.channel.id == ctx.channel.id
and str(r.emoji) in ["🔄"]
)
async with aiohttp.ClientSession() as session:
newword = quote_plus(word)
url = await session.get(f"https://api.datamuse.com/words?rel_rhy={newword}")
urlJSON = await url.json()
rdn = random.choice(urlJSON).get("word")
success = await ctx.reply(f"Word: {word}\nWhat rhymes: {rdn}")
await success.add_reaction("🔄")
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=30.0,
)
except IndexError as ie:
await ctx.reply(f"There are no words rhyming with {word} :(")
except asyncio.TimeoutError:
pass
else:
newWord = random.choice(urlJSON).get("word")
if str(event[0].emoji) == "🔄" and not event[1].bot:
await success.edit(content=f"Word: {word}\nWhat rhymes: {newWord}")
else:
pass
its a func, sure but like
here is the code
anyone?
i read it wrong, i thought it was like a variable i didnt read the paste (sorry lol)
!global
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
lemme Google it
why are u typehinting to user lmfao
Shoot
right?
Use a wait_for
my code is dumb
bro reread my code i am
same piece of code work for the other command but doesnt work for the other one
maybe check if event is True?
in what condition would the event be true
who needs helping hm?
me
whats the problem
check this out
no problem, just trying to figure out how to make the bot listen to all reactions, not just one.
my code isnt working in the way it should
⬆️
you’re doing and str(r.emoji) in ["…"] … just remove that
alr
event
Never mind
what
You did event = …. you can check if event is True
im kinda on mobile so don’t trust anything i say 😳
im asking in what state is the event true, like for example it turns true when the event is successfully triggered
Me too 😳
Yes
What does ratio mean

I know what ratio means
btw help
I just don’t understand why people say “ratio”
kekw
😂
the only reason i’m not helping is cus i literally cant - if you use global your entire code turns into airborne cancer and it’s impossible to fix anything
i said "successfully triggered" and the event only triggers once...
...
💀 i love this channel
global in discord bot = shoot me in the fucking head
? You want it to keep listening?
yes
then what i do sir
~~I use global
~~
remove global and make a new bot
:/
:| im glad i don't use global
Use bot.listen()
man you’ll probably go back in time and kill your previous self when you realise what you’ve been doing
I already did
but it's in a command...
bitch idk I’m on mobile
that was slightly rude x[
hurrrr
Sorry for my outburst
so what do i add inside
forgive ya
Remove global
i created a file called cancer.py and put global in it x.x
Make timeout=None
i created a file called hangman.py and put global in it (no i just copied hangman somewhere x])
That would keep listening
you wanna be more ironic? :D
I hanged a man one day
it sound's so geniusly true that i think it won't work
i even made pseudocode for it
for using global
Try it at least
caedan is fucking good at roasts: "airborne cancer" 💀💀
... fine
Caeden used to be pretty toxic 💀
if you spell my name wrong again you’ll be at the other end of the toxicity
But now he’s pretty cool 💀
who said i’m not still toxic? 
you don’t seem toxic to me
eh i’m not actually that toxic
you’re sometimes toxic when you help though lol
until i get muted for calling someone braindead
a bit like kraots and me when people don’t understand what’s happening because they copied and pasted code
wait... mini.. are you the mini i think you are?
so are u done with ur toxic shit and are u going to help me
I got muted for telling people to shut up

ok but caeden what about my thing i wanna change, timeout=None still listened once 💀
Oh…while True?
What was the problem again?
you need to make it loop the wait_for because they only trigger once
forget it
💀
well, the thing i was stuck in was the positioning of the loop
you can use a walrus for it to be nice and neat
Like a while True?
Walrus? 
im trynna make a imagine trigger using on_message but not sure how to cut out the first word ("imagine")
someone did tell me to use a loop, but what striked me was the positioning of where the loop would be
? Wdym
e.g. someone says "imagine this and that", only "this and that" will be returned
while True: event = bot.wait….
so like this - while (message:=await bot.wait_for("message", check=…, timeout=…): that’s all you have to do if you want it to loop endlessly with a walrus. However, if your python is lower than 3.8 this won’t work because walrus is implemented in 3.8. Instead you can do; py message = await bot.wait_for(…) while True: … message = await bot.wait_for(…)
hm
wasn't that an example?
that’s how to loop it, either work
😃 🔫 my code even looks like airborne cancer
… represents the code you want to do inside
Yes
if the try fails then the loop breaks soo you can’t break out of a loop that’s already broken out of
i feel like naming conventions are lost on you @shadow wraith
wdym by naming conventions
pls help
use discord.TextChannel
replace it with discord.abc.GuildChannel
okay
come on you don't have to call them that when literal opinions exist x[
cant u remove those not so helpful words :/
this would be fine but just copy the event = line to before the while true
!d discord.abc.GuildChannel
class discord.abc.GuildChannel```
An ABC that details the common operations on a Discord guild channel.
The following implement this ABC...
sure sure
!d discord.TextChannel
class discord.TextChannel```
Represents a Discord guild text channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channel’s hash.
str(x) Returns the channel’s name.
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=None,
)
while True:
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=None,
)
this good?
there should be no opinion in naming a variable - you call it what it returns and follow naming conventions
!pep 484 i think this is the one lemme check
fuck not that one
type hinting ???? 💀
oh it’s pep-8
for naming conventions
what if i just name it sql statements like WHERE 💀
😄
oh yeah @manic wing i did the while true thing you told me to do, now it doesn't listen to any reactions at all :[
according to my calculations it seems like you’ve done something wrong :O
show me the code
oh i see
dude
print(event) inside the while true loop
before the second wait_for
the second wait_for needs to be the very last line in the while true
sure but that'd just endlessly print event
fuck i tried it now it just prints the info about the event, no edits :[
why while true
istg if this problem doesn't get fixed today im gonna drink water
so that the wait_for waits for multiple events
if you put a wait_for at the end of a while loop then it waits till the event and when it hits it it reenters the loop
do i have to add more shit or
so why not a task
because the event literally never gets triggered now
I mean
if you use the while correctly it's not a problem
this code is not task-loopable:
@bot.command()
@commands.guild_only()
@commands.cooldown(1, 3, BucketType.default)
async def rhyme(ctx, *, word):
try:
def check(r: disnake.Reaction, u: Union[disnake.Member, disnake.User]):
return u.id == ctx.author.id and r.message.channel.id == ctx.channel.id
async with aiohttp.ClientSession() as session:
newword = quote_plus(word)
Api = await session.get(f"https://api.datamuse.com/words?rel_rhy={newword}")
API = await Api.json()
randomWord = random.choice(API).get("word")
__what_rhymes__ = await ctx.reply(
f"Word: {word}\nWhat rhymes: {randomWord}"
)
await __what_rhymes__.add_reaction("🔄")
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=30.0,
)
while True:
print(event)
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=30.0,
)
except IndexError as ie:
await ctx.reply(f"There are no words rhyming with {word} :(")
except asyncio.TimeoutError:
pass
else:
newWord = random.choice(API).get("word")
if str(event[0].emoji) == "🔄" and not event[1].bot:
await __what_rhymes__.edit(content=f"Word: {word}\nWhat rhymes: {newWord}")
else:
pass
or if it was, it'd be too complicated for me to even understand it
:/
what'd the expected outcome?
ping me when you come up with a solution, ima go
#main.py
from emote import emote
@bot.command(name='craft')
@commands.cooldown(1, 1, commands.BucketType.user)
async def craft(ctx, arg: str):
await item(ctx)
emote()
embed = discord.Embed(
description= f'''
`pog_helmet` ↦ 50 {epogchop} + 50 {ecoal}
''',
color = discord.Color.blue())
embed.set_author(name= 'Recipes(Page 1)',
icon_url = ctx.author.avatar_url)
embed.set_footer(text = 'imagine forgetting recipes')
await ctx.send(embed=embed)
#emote.py
def emote():
epogchop = ':pogchop:'
ecoal = ':coal:'
ebeef = ':beef:'
eiron = ':iron_ingot:'
ediamond = ':diamond:'
ewool = ':wool:'
egold = ':gold_ingot:'
enetherite = ':netherite_ingot:'
eredstone = ':redstone:'
```is this how u do it?
the lack of PEP8 though
indents...
@shadow wraith what are you tryna do?
And indents
i’ll code it
?
Spoon feeding now, huh?
what indents
cough definitely not spoonfeeding
emote()
embed = discord.Embed(…
on a serious note, if i know what he wants to do i can write a detailed explanation with examples without actually spoonfeeding
That’s so smart
!indents
---> Sending a quote on a timer
you're going to want to have 3 things:
a) a list of channel ids
b) a database to store the channel ids - it can just be a json file, but you probably want the bot to remember to send the quotes, even if you restart the bot.
c) a discord.ext.tasks.loop.
In this example I am going to show how you may want to do it, but I will not show it linked to a database. You can do that part yourself. My github project where I have done this is https://github.com/caedenph/jesterbot.
@tasks.loop()
async def quote():
### Get channel_ids from database here ###
for chan_id in channel_ids:
channel = bot.get_channel(chan_id)
await channel.send(quote)
in this example there is channel_ids, which holds the channel ids, and tasks.loop which is discord.ext.tasks.loop
You can also link this to a command,
@bot.command()
async def setup_quote():
#apend to database```
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
like this
oo there is a if loop between them i remove it so u all can understand it easier
why the bot slow
Bro
oh it's not
Wdym
lemme show u ori
You should have included the if statements
@bot.command(name='craft')
@commands.cooldown(1, 1, commands.BucketType.user)
async def craft(ctx, arg: str):
await item(ctx)
emote()
if arg == '1':
embed = discord.Embed(
description= f'''
{eph} `pog_helmet` ↦ 50 {epogchop} + 50 {ecoal}
should have the indentation aliase 😠
the if arg == '1':
sry ;-;
We’re not mind readers
Aliase 😭
@shadow wraith explain what you want to do
i thought it will make u all understand easier
speak for yourself
When we see bad indents 👀
;)
Shut up
:/
:( meanie
dunno
What’s the problem anyways @loud junco
Speak for yourself
that don't even make sense now

all of those epogchop, ecoal... are not defined
what’s happening
What
def emote():
epogchop = ':pogchop:'
ecoal = ':coal:'
ebeef = ':beef:'
eiron = ':iron_ingot:'
ediamond = ':diamond:'
ewool = ':wool:'
egold = ':gold_ingot:'
enetherite = ':netherite_ingot:'
eredstone = ':redstone:'
do bot.epogchop =...
you posted this yesterday
That’s systematically impossible
What i just said doesnt even make sense xD
at where
Ah~
lemme try
so what do i do
This ig
from here
🤦♂️
hi
Hi
Also the lack of PEP8 is astounding
Guy’s probably using VS Code or something
That bad IDE lmfao
he legit holds a dictionary in his hands
lol
?
Was that meant to be a joke
yes
Hmm, I saw the deleted message I got ss
I dont trust anyone
i like it when paypal gives me chlamydia
tryna make payments and it rejects them but charges my bank 
Depres
def misuse_embed(command_name, cooldown = "No cooldown.", usage, example_usage): why is this giving me error?
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.IncorrectUsage' raised an error: SyntaxError: non-default argument follows default argument (IncorrectUsage.py, line 4)
you’ve made cool-down optional but usage and example_usage which aren’t optional are behind the optional
which doesn’t make much logical sense
hence why python doesn’t like it
ye ok
Hello
👋
@velvet tinsel what bot do you have?
yeah show us
That was a very sudden and random question that slightly startled me
?
show us your bot
we’ve seen kayles nub bot
and we’ve seen my sexy bot with 28 cogs and 240 commands ;)
now we wanna see yours
true
what collab
On a bot
what bot
I guess
Idk, some random bot
Totally not flex
its of course a flex
why would i do anything other than flex
mmmm, need help?
so you dont have one?
No
No
whats the github
@manic winghopefully u have changed your api keys
only one is visible and its the nasa one
'x-rapidapi-key': "1c0ae8ee8emsh7bd54f2151cc278p1a0f3djsn9212745a468e",
'x-rapidapi-host': "fixer-fixer-currency-v1.p.rapidapi.com"
}```
what command is that? o.O
leaking private information
probably forgot to change it after testing
Also
ban
I’ll make a bot today
eh all the apis i use are easy to get keys for
copied
its not so private when its posted public...
And I’ll preview it
oh my friend made that command
zamn! nice api key
not my api key 😎
😛
I’ll make a bot
there are a couple more api keys if you wanna find em
same
😡
i can think of 2 off of the top of my head
And I’ll preview it I guess
👹
@client.command(pass_context = True)
async def mute(ctx, member: discord.Member):
if ctx.message.author.server_permissions.administrator:
role = discord.utils.get(member.server.roles, name='Muted')
await ctx.add_roles(member, role)
embed=discord.Embed(title="User Muted!", description="**{0}** was muted by **{1}**!".format(member, ctx.message.author), color=0xff00f6)
await ctx.send(embed=embed)
else:
embed=discord.Embed(title="Permission Denied.", description="You don't have permission to use this command.", color=0xff00f6)
await ctx.send(embed=embed)
Any guesses why this command doesn't work?
i didn’t make that cog
i don’t think i did at least
guild_permissions
not server_permissions
also discord not disnake, passcontext deprected, client not bot, server a lot not guild, ctx.add_roles doesn’t exist
i think i made most of them
@manic wingfred?
maybe like +/-5
i didn’t make end world hunger command x.x
basically:
find rhyming word which rhymes with word from api
add a reaction
if user reacts to reaction
use a new rhyming word
if user reacts to the reaction again or more
use more rhyming words
huh
huh
Which API
so it goes through rhyming words as the user reacts
https://www.datamuse.com/api/ i think its
cheers, thats a new command for me
alright gimme 30 min to get home
Is it just me or are programmers pretty laid back
in 30m mins i am kinda busy
well i’m not writing a longass paragraph on mobile so it’s 30 min
righting x]
you can read what i wrote whenever you want
You’re write!
Your'a rong
You’re write that we should you righting instead of writing

i agree, i got 35 min of sleep last night and i’m fine for the moment
for the moment
i’ll conk out soon
I slept till 10, I fell asleep at around 1 and I’m tired
get better sleep smh
The shortest I’ve ever had was 4 hours
i pride myself in getting good sleep
I was fine for the day
rookie hours
Then I got knocked out
8-10 hours a day
last night was an exception
Are you 10 years old or something
i got like 8-6 hours i think
i was on a plane
I sleep for 10 minutes on a plane
i was on a plane like 3-4 days ago, never got sleep :[
Rookie minutes
i try to shoot for 12 hours :D
Sometimes I don’t get sleep
I refuse to sleep
same
What
the better sleep you get the better coding you can achieve
I try sleeping but the plane has a weird atmospheric pressure that doesn’t let me sleep
oh yeah and there was this baby and kids running around the plane
Oh, that explains why I couldn’t solve a JSONDecodeError
I refuse to sleep
followed by
I try sleeping
one had a spray and came near my sister 💀
💀
thanks
Lovely
What do you spend your money on
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Let’s go to #ot2-never-nester’s-nightmare
how can i get user message content in bot.listen
what event in bot.listen
?
for example if they type .hello hi the bot says user said hi
Bro, what
That’s a command
ik
you can have multiple events with bot.listen?
but i want it .listen cause i already have a command like that
as in
Yes
can i make more than 1 command with same name?
no
Uhhh…no
However it is possible
use your noggin
what i do then
change the name of the command? 
It is technically possible
i dont want to do that
hm?
However it will cause confusion
🤮
probably
how would it be idk how
Dont do it though
__builtins__["print"].__call__(_message_.content.__str__() or None if not None) this will print the content
if esoteric is your cup of tea
hm
bruh
each to their own
it would work…
Well
It’s preferable not to have two commands of the same name
The computer can’t read minds
u cant even have 2 commands with the same name
be more esoteric, use gettattr
@commands.command()
async def viewfeedback(self, ctx: Context, distance:Union[int, str]=0, author_from:Union[int, str]=None):
await thebed(ctx, '', '**Error: **distance must be an integer (an index placevalue) if no `author_from` is given!') if hasattr(distance, 'upper') and author_from is None else await thebed(ctx, '', f'*`{distance}`*: "{data["feedback"]["message"][distance]}", submitted by **{data["feedback"]["author"][distance]}**' if distance != 0 else f'**You can index off of the index on the left side. Type `{ctx.prefix}viewfeedback <index>`\n**\n' + "\n".join([f"`{num}:` {data['feedback']['message'][k]}**, said by {data['feedback']['author'][k]}**" for num, k in enumerate(range(len(data['feedback']['message']))) if num <= 9]), a='Feedback', i_u=ctx.author.avatar.url) if author_from is None else await thebed(ctx, '', f'\n'.join([f"`{num}`: {data['feedback']['message'][num]}" for num, k in enumerate(data['feedback']['author']) if k ==author_from]), a=f'Feedback from {author_from}', i_u=ctx.author.avatar.url, f=f'All these messges are from {author_from}') if hasattr(author_from, 'upper') else await thebed(ctx, '', f'\n'.join([f"`{num}`: {data['feedback']['message'][num]}" for num, k in enumerate(data['feedback']['id']) if k ==author_from]), a=f'Feedback from {await self.bot.fetch_user(author_from)}', i_u=ctx.author.avatar.url, f=f'All these messages are from {await self.bot.fetch_user(author_from)}')```
very good command
imagine making mistakes
Not Caeden
question of the day :3 how to make my bot send cooldowns of commands
!d discord.ext.commands.BucketType
No documentation found for the requested symbol.
he's in hypesquad briliance, maybe just 1 - 2 months
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
@small igloo
How would I add a specific role to a user with there ID?
me to E
Where ID
?
how to use dat :V
how can i get mentioned user name?
Read the docs
I’m gonna leave
You guys don’t Google stuff
nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
xd
@velvet tinsel
got it
.
@manic wing can you send the API documentation
Are you gonna write a genius paragraph yet
role = get(message.guild.roles, name = "test role")
await ids.add_roles(role, atomic=True)
would that work, as I already got the user ID I want to add the role too.
How can i get only last word of {message.content}
You got to split the strings up
idk how
accidentally sent it prematurely
how can ModMail send DMs to mods :v just curious
🤦♂️
Just Google it
What don’t you get about fucking Googling it?
It’s the simplest thing on earth
This is a help channel, your not being much help asking people to google it.
They should Google it first
They might of already done that.
I doubt it
the mods are gonna mute u if they see this you know that right? 💀 🖐️
I’ve been muted 3 times
then a ban is next
Cool
Is it good to have on the output the
'python' is not recognized as an internal or external command, operate program on batch file?
On the output
not terminal
!enumerate || So you're going to want to make the aiohttp.ClientSession and have 2 variables;
-> word which holds the base rhyming word
-> rhyming_words which is a list of all the words that rhyme with word
-> iteration_number which is an int of value 0 just holding the index that rhyming_words is on. this can also be dynamically created and executed within the wait_for loop but for simplicity we can just make it manually
I never want to see you do __what_rhymes__ as a name again
you're going to send word and call the message message; add_reaction to it.
then you're going to create your wait_for and unpack it into reaction, user seeing as wait_for('reaction_add') returns a tuple. Assuming your python is v3.8+ we can use a walrus for the loop ```py
while (reaction, user := await bot.wait_for('reaction_add', check=..., timeout=...)):
this is all you have to do for the loop to continue.
if reaction == your_emoji:
new_word = reprocess(iteration_number)
await message.edit(content=...)
#where reprocess returns the rhyming_word so that message shows the new rhymed word```
reprocess can have the check so you dont even need a try/except block. py def reprocess(iteration_number: int) -> str: #iteration_number is the int we defined earlier to keep track of which rhyming word index we're on. if len(rhyming_words) -1 > iteration_number: #there are not enough rhyming_words left, they have all been used. return "No more rhyming words" return rhyming_words[iteration_number] #returns the rhyming word
Ever find yourself in need of the current iteration number of your for loop? You should use enumerate! Using enumerate, you can turn code that looks like this:
index = 0
for item in my_list:
print(f"{index}: {item}")
index += 1
into beautiful, pythonic code:
for index, item in enumerate(my_list):
print(f"{index}: {item}")
For more information, check out the official docs, or PEP 279.
not sure how useful that was 
anyone
how can i get mentioned user name?
thats more of a python-general questio
That’s amazing
its about discord bot
I love you Caeden
Well the question isn’t related to discord bots
i feel like i underperformed
You did it perfectly
ty :)
😄
how can i see doc
see what
Wdym
documentation
what module are you using
How to access variable from a different function in cogs?'
I tried using global
commands.Cog.listener()
async def on_ready(self):
f = open('templates.json')
global template_ids template_ids= json.load(f)
disnake
well so discord
Never mind
how can i see it
thanks
I am a bot coader is there anyone here to join my team
Cool
The variable is in your cog?

yes
I have defined a variable called 'prefix' within my bot.py file which can be used in commands later, such as be displayed to the user. It's purpose is to simply store the bots prefix.
However, I c...
In your optical illusion I see a panda
dude chill #code-of-conduct
♥️ reminds me of Pandabweer
Cool
so what are the other libraries I can switch from discord.py as it's now dead anyways
dont change
But I'm asking about retrieving it from a different function in the same cog file..
Ok
can I ask why? I'm pretty sure it doesn't support ui buttons
it does
Discord-interactions
can't find the Documentation ,can you send it ?
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
ty
why use external libraries when you can not use them
Hi
!d discord.ui.View <=
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
@visual island make a bot w/ me
what bot
Anyone have a good video for learning classses
who knows
read the pins
Ok
I can't think of any "unique" bots
make a bot that makes a bot inside a bot
Very unique
the key to having a popular bot is having it be unique and wanted
how would that work
Don’t work with Caeden
i cant think of either of those two :p
why not? :(
why not
Requests
to?
i know my cogs jeez ... most of them at least ;)
See
dude it is kinda hard to remember all 240 commands
Bro my code is so fucking messy
use black?
No I just don’t use cogs lol
Caeden, what IDE do you use?
that's not possible..
visual studio code
No wonder
...
Your code must be really messy
I was kidding lol
yeah so you give the idea and I code, thanks
async def on_message(message):
if message.author.bot:
return
else:
if ".timeout" in message.content.lower(
):
await message.delete()
await message.channel.send(
f"{message.author.name} timeouted for {message.content}",
delete_after=10)```
how can i get mentioned name here
like the user that its mentioned
I like code quality more, than the amount of commands
i code you give ideas, deal
Use command(), I don’t know how to work with on_message
no
my code is always great quality and sexiness
Me too
@velvet tinsel you'll give the idea, deal
No
use commands..
@manic wing help me
I’m terrible at ideas
me 2
I spent 10 days thinking of a bot name and all I came up with was “bot”

bruh
yes yes icy dekriel gives the ideas and we code it :D
Noooo
we need like 20 people for the ideas and 2 people to code it
remake dank memer in 2 days and you'll code it
*and very little if elifs
i cant think of a single use of elif
you'll not make it for sure
do it now
Ok
sometimes it's useful
I love it
but cant think of any good use of it
yeah i was overexagerating
so i need a code on the bot dming the member after they're kicked from the server
well you would have to check audit log for kicks becuase on_member_remove doesnt inherinhtely show how they left
Would you like to use my dank memer when I finish with it @manic wing 
why do i have to check audit logs#
if I can script it again <3
because you said kick
Does it have to use a the dank memer profile picture
@fervent shard is this for a command?
yes
no, just the commands
dekriel one condition - your dank memer bot cant use json
that too
and what i need is a code on the bot dming the member after they're kicked from the server
I’ll use mongoDB
postgres when
before you kick them, you send a message to the member
yes
but i need the code
The commands look easy
make it
no, you can use discord.Member.send to send a message to a member```py
member = ...
await member.send(...)
ok so icy
Chill
it doesn't recognise view```py
@commands.command()
async def rrole(self, ctx):
but = Button(label="E", style=discord.ButtonStyle.primary)
vb = View()
vb.add_item(but)
await ctx.send("X", view=vb)
error?
you joining?
um, I'll let you decide 
Remake dank memer
send() got an unexpected keyword argument 'view'
How do I make commands not case sensitive?
😏
are you using discord.py 2.0?
if u have the code for it pls tell me @boreal ravine
yes
case_insensitive=True in your bot's constructor
Yes
A
B
well then that error shouldnt raise
bot's constructor is this line yes?
client = commands.Bot(command_prefix=get_prefix, help_command=None)
yes
yes
thanks 🙂
Yes
np
djs better imo
Yes
as you mentioned the id of the channel the command was run on?
nah
💀
why so?
. . .
?
exact version
discord.py 2.0.0a3575+g45d498c
djs is an entire library, made from scratch while dpy forks were forked from dpy
u tell me y would u like djs more than dpy
^
, i mean that dpy and its forks
so what are we all making
dn noʎ ǝʌᴉƃ ɐuuoƃ ɹǝʌǝu
maybe you didnt uninstall ur other dpy?
print(discord.__version__)
Dank memer clone
what
no
what do you guys think of a jarvis bot
Wdym
you know jarvis from iron man
2.0.0a
where you can tell him to do shit
Oh yeah
Good idea
!d discord.TextChannel.id use Context, ctx.channel.id
The channel ID.
how to uninstall them
so you just type like 'hey jarvis, ban fred'
Good idea
pip uninstall discord.py==version
kayle icy, your thoughts?
idk, how are we gonna make it together though?
i want everyone on this project
github
Including me? 💀
sure I'll just follow every idea
i make a repo and everyone here is apart of it
I don’t give a shit about ideas
yeah but you're making pulls not commits cus i dont want dirty non-typehinted code 😻
😭 ok
jk
I typehint
is this a thing we wanna go through or is it a one day kinda thing
Idk
i can make a gc with us in it
reinstalled discord.py still same issue
what does await member.send(message) do
DM
sends member a message 
it dms them?
Correct
My comment touch a nerve?
this is non-voluntairy
what version did u install..?
Wdym
you work on this project or you're disowned
2.0.0a
ok
@boreal ravine
from where?
pip install -U git+https://github.com/Rapptz/discord.py used this
How to make bot respond both to slash and non slash in disnake?
do pip freeze and see if you have any other old dpy libs ig
kayle add me
Ok
what is friend now
Idk
mm idk
how would i send the dynamic time things?
help when i kick my alt the bot doesnt send my alt the message
<t:1640873646> this?
ye
show code
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ty
How do I make link to a channel in DPy?
or to a user since it might be useful soon as well
like that
<#id>
User.mention , Channel.mention
if you want to send it as a message
Thanks 🙂
Anyone know how to find out weather or not a person has a specific role
Let me test
role in Member.roles returnS True if the Member has the role
for role in mag.author.roles?
No , it's a condition to use with if
if role in member.roles:
#they have the role```
hey sarthak you are experienced with libs like disnake or discord.py right
If “vip” in msg.author.roles?
Yeah kindof
No it needs to be a role object , not the name
do you have the role id or something?
Id?
becasue im gonna ask a question which is gonna be a lil' hard for most people, i did try what they said but they resulted it a misunderstanding or just didn't work
sure you may ask...
@bot.command()
@commands.guild_only()
@commands.cooldown(1, 3, BucketType.default)
async def rhyme(ctx, *, word):
try:
def check(r: disnake.Reaction, u: Union[disnake.Member, disnake.User]):
return u.id == ctx.author.id and r.message.channel.id == ctx.channel.id
async with aiohttp.ClientSession() as session:
newword = quote_plus(word)
Api = await session.get(f"https://api.datamuse.com/words?rel_rhy={newword}")
API = await Api.json()
randomWord = random.choice(API).get("word")
__what_rhymes__ = await ctx.reply(
f"Word: {word}\nWhat rhymes: {randomWord}"
)
await __what_rhymes__.add_reaction("🔄")
event = await bot.wait_for(
event="reaction_add",
check=check,
timeout=30.0,
)
except IndexError as ie:
await ctx.reply(f"There are no words rhyming with {word} :(")
except asyncio.TimeoutError:
pass
else:
newWord = random.choice(API).get("word")
if str(event[0].emoji) == "🔄" and not event[1].bot:
await __what_rhymes__.edit(content=f"Word: {word}\nWhat rhymes: {newWord}")
else:
pass
why does this listen to one reaction, why can't i just make it listen to all reactions until timeout
"role object" , which you can get by msg.guild.get_role(id here)
wait_for listens to the event for once , you might use while True to keep it looping until the bot doesn't get a reaction for a long time
yup another while True: response, so where would the loop be?
Ok and how do i get member
while True:
try:
res = bot.wait_for("reaction_add" , timeout =)
# stuff u want to do
except asyncio.TimeoutError:
break
Msg.author?
If you want it to be the user who sent the message , yes
So it would then be role in msg.author.roles
Yep
does this mean i have to move the entirety of my try and except and else statements into a while True: loop
Only the things you want to do on the reaction being added
You don't need to
if that's not related to listening to reactions , which I don't think is
what's the command to install discord-py-slash-command
that only works for discord.py 1.7.3 but if you want to install do pip3 install discord-py-slash-command or pip install discord-py-slash-command
ok ty
my else statement is
Error - Command raised an exception: TypeError: send() got an unexpected keyword argument 'view'
@commands.command()
async def rrole(self, ctx):
but = Button(label="E", style=discord.ButtonStyle.primary)
view = View()
view.add_item(but)
await ctx.send("X", view=view)
what discord.py version are you using?
2.0.0a
How to disable all the buttons after I am done with interaction
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
What check bro
ok but would it still do the other shit it's meant to do or the while True loop is the new place which holds everything
So how do I disable all the buttons in get_value?
Wrong tho
just type /
reaction, user = ...

