#discord-bots
1 messages ยท Page 700 of 1
but this shits annoying
well if it doesnt work...then youve fucked something up - dont say 'nah' until it works
file = open("channels", "r")
channel_list = file.read().split()
file.close()
this is the list
file.read().strip().split()
stil nothing
can you show all the code
@client.event
async def on_ready():
await asyncio.sleep(1)
servercount = str(len(client.guilds))
usercount = str(len(bot.users))
activity = discord.Activity(type=discord.ActivityType.watching, name=servercount+" servers [a!]")
await client.change_presence(status=discord.Status.online, activity=activity)
file = open("channels", "r")
channel_list = file.read().strip().split()
file.close()
print(channel_list)
for channel_id in channel_list: #where channel_list is a list of id's
channel = bot.get_channel(int(channel_id)) #searches bots cache for the channel
embed = discord.Embed(title="> __Channel inactive__", color=0xFF0000)
embed.add_field(name="Reason for inactivity", value="```Restart by developer```", inline=False)
embed.add_field(name="Note", value="```Small bug fixes || Added new categories```", inline=False)
await asyncio.sleep(3)
await channel.send(embed=embed)
why do you have some client then still...ctrl + r it all to bot
rn client is defined as bot
pls replace all client instances with bot
doesn't matter
idk how tf client.event is working if its called bot
cuz client = bot
seeya
intents.members = True
bot = commands.Bot(command_prefix="a!", intents=intents, status=discord.Status.online, help_command=None)
client = bot
wtf bot.users are you using client or bot ๐
both ๐คฆ
same
yeah
How can I get every emoji in a message?
@bot.event
async def on_message(message):
for message.guild.emojis in message:```
Something like this
let's run to #python-discussion
i go to help channels
for emoji in ctx.guild.emojis:
I google it ๐ถโโ๏ธ
This gives me every emoji in the server. But I want to check every emoji in a message a user has sent
ah~
well
I did some googling
"That's not how discord relays emojis afaik. In discord.py, native emojis are represented either by their unicode string (\U0001f44d) or by the emoji "image" itself (๐), not by their Discord reference (๐). You'll need an "emoji list" to check against for native emojis, there are some python packages that you can try as well here's the first one that pops up on pypi emoji.
For custom emojis, you can do something like this:
if any(str(emoji) in message.content for emoji in message.guild.emojis):
#do something with the message
But that will only check against custom emojis that are in that specific guild, not custom emojis from another guild. To check for external custom emojis you'll probably need to use a regex."
Your iterating through all the emojis of the guild where the context of the command was invoked?
nice pfp btw
Thx
Shh
Alr tried. Not working

google it please ๐ถโโ๏ธ
You love google
it's my ex
Wife*
you legit just copy and pasted my code I found on reddit
I cannot use the emoji
how dare you
variable
I'm sorry D:
because you didn't define emoji
emoji = discord.Emoji ?
coding is my wife, get your facts right
๐ถโโ๏ธ
Guess your gonna get a divorce because you arent good at it
*aren't *you're
get your grammer right
and *going to
I was implying sarcasm
Sure you were
@velvet tinsel have you seen timeouts?
yes
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
uwu
Pretty nice
Please tell me how to make the bot load slash commands on all servers?
You mean to register slash commands on all guilds?
Ill add a command for it
yea
that's my girl
Youll have to wait 1hour i think or a day
What for?
If just for some guilds use test_guilds=[]
I think it is for some guilds
Why then does this error occur?
Idrk show code
You dont follow it either
Why is
self.bot
A thing
says the guy who doesn't put spaces after the hashtags
it's for cogs
๐ถโโ๏ธ
You add 1 its 2
You can just type hint it
that's not what PyC says
and also you don't even add any
yea
Hello ๐
merry christmas
hi
Oh yeah 3 days for Christmas forgot about Christmas
2 days until Christmas but merry Christmas to you
that's the day I count as Christmas because everyone celebrates it at this day
I dont lol
All my family celebrates it the 25
the 25th day is just a second day for it, well eating what ever is left from 24th day and just smth random
but this is a bit offtopic
Isnt the 24 the day before it hence the name "eve"
ยฏ_(ใ)_/ยฏ
Lol
Atleast my indents are clean

Dont make me show your google command

how can i check if a member has perms to timeout?
with the
@commands.has_permissions()
decorator
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
Ye
Np
Is it possible to put multiple views onto a message?
For example as an array like this:
await channel.send("Hello there", view=[view1, view2])
why exactly?
well, because I have two different view classes that I want to put onto one message, and I don't want to create a separate view class to combine them together because it's just gonna take up a lot of space
You can just have one view class and just add ActionRow objects
Each of which can have their own components
Can you show an example please?
#bot-commands please
oh my bad
Not gonna write an example, but should be just like creating buttons but instead you create a ActionRow and then add buttons to them
this hurts my eyes
class discord.ActionRow```
Represents a Discord Bot UI Kit Action Row.
This is a component that holds up to 5 children components in a row.
This inherits from [`Component`](https://discordpy.readthedocs.io/en/master/api.html#discord.Component "discord.Component").
New in version 2.0.
Is there a way to attach a few different views onto an action row?
or is it just buttons?
Views no, buttons yes but it's not just buttons and instead every message component
.topic
searches for anime girls dont ask why
I don't even want to know why
Suggest more topics here!
uh
nuke
even dank memer
buttons and not reactions
yo my least favourite feature is paginators that require manage message perms
Has discord raised the reaction add endpoints rate limits yet again
Might as well just kill the archiac reaction paginators
yikes
did it raise it?
Can't remember but this is a pretty high rate limit
Expires in 2026 ๐๐๏ธ
No wait I was looking at the wrong thing ๐โโ๏ธ
Has youtube changed their policy on downloading/streaming videos? Mee6 has reimplemented their music feature
my commands arenโt working, can i show someone my code because idk what i did wrong
i need help
does client.get_channel() work with intent or without?
well caeden and andy and kraots, it's a field day for you to answer these questions
I'm gonna go sleep
this is what everyone do in this channel lol
Which intent๐ค guilds?
no need for intents
idk what other software to use ๐ญ
you have to tell what is the problem we can't check all your code
PyCharm
you can use vsc
Ehm, pycharm? lol
itโs not that long tbh
ew
Vsc
copy paste it here
itโs the @bot.command
Gn bro
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.
Wait show me ur code
he's using bot.command()
import discord
import os
import requests
import json
import random
from discord.ext import commands
from discord import Member
from discord import Embed
from replit import db
from keep_alive import keep_alive
bot = commands.Bot(command_prefix=";")
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
@bot.event
async def on_message(message):
if message.author == bot.user:
return
@bot.command()
async def lyric(ctx):
await ctx.reply(random.choice(gracie_lyrics))
@bot.command()
async def instagram(ctx):
await ctx.reply('https://www.instagram.com/gracieabrams/')
@bot.command()
async def intro(ctx):
await ctx.channel.send('https://open.spotify.com/playlist/51TIRdARgx0ewyPr1PbuoX?si=nw_iyfHLTaiWRWqFVVYXPw')
@bot.command()
async def pic(ctx):
await ctx.reply(random.choice(gracie_images))
@bot.command()
async def track(ctx):
await ctx.reply(random.choice(gracie_tracks))
@bot.command()
async def project(ctx):
await ctx.reply(random.choice(gracie_projects))
@bot.command()
async def cover(ctx):
await ctx.reply(random.choice(gracie_covers))
@bot.command()
async def ping(ctx):
await ctx.reply('pong!')
@bot.command()
async def commands(ctx):
await ctx.reply('__**GRACIE ABRAMS COMMANDS**__\n\n`;cover` โ **sends a random project cover**\n`;instagram` โ **sends gracieโs instagram**\n`;intro` โ **sends introduction playlist**\n`;lyric` โ **sends a random lyric**\n`;mv` โ **sends a random music video**\n`;pic` โ **sends a random picture of gracie**\n`;project` โ **sends a random project**\n`;track` โ **sends a random track**')
keep_alive()
bot.run(os.getenv('TOKEN'))
what's wrong
thatโs not the whole code, the gracie_covers etc are image files
U need intents
glad you missed out all the links
what
ok first no need for intents
so what do i need to do
and second no need for that on msg event
it works fine to me
yeah ik but the commands on discord donโt work
so what then?
bot = commands.Bot(command_prefix=";" , intents = ...
what do i put in the โฆ
delete what
no need for it
msg.event?
He needs intents for on_message event
yeah
this
@bot.event
async def on_message(message):
if message.author == bot.user:
return
it's useless lmao
no he doesnt
yeah it's useless
Wym useless
so i delete that, and my commands will work?
it doesn't do anything
probably
๐๐๐ he needs intents to access that event
idk just delete it
you're using event
no you dont
bro lmao
learn python
anyways you could have used listen
Tnx for the advice
OH MY GOD
you're welcome
learn discords api*
@velvet tinsel you were right my man
true
i love you
what
bro
hold up ๐ณ
Try on_message event without Message intent and see if it gon work
it does
dekriel didnt do anything wtf
I used it before
yeah I'm confused
Proof?
yeah hol up
^
it's kinda weird but here it is
no need for intents on a msg event lmfao
no need for this
from discord import Member
from discord import Embed
alright
guys
@client.listen()
async def on_message(message):
if message.startswith("tian")
...yeah it's cringe
bot*
I did listen() since if I did event it brok
and your wrong
*your and elaborate
Traceback (most recent call last):
File "main.py", line 74, in <module>
async def help(ctx):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1263, in decorator
self.add_command(result)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1149, in add_command
raise CommandRegistrationError(command.name)
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
itโs saying that
there's already a help command
@bot.listen("on_message")
async def on_message(message):
if message.startswith("tian"):
...yeah it's cringe
not for me
hur?
yes for you
i donโt see another help command
arent listens like that?
you get a default help command
DPy already includes a command named help so you can't use it unless you remove it or replace it.
how do i remove it
?
how do i remove it / replace it
it's already built in
i want to remove it
no?
and replace it
help_command=None iirc
bot.remove_command("help")
bot = commands.Bot(command_prefix=";",help_command=None)
or bot.rem damn it, papi already said it
help command kwarg is better
bro you can't just pretend that you can code a bot without first studying how it work. Search for tutorials, examples, everything but first study, those are really the basic thing
bro ๐ญ
thats the prefix
that's just the prefix
prefix sucks
welp
tbh
it worked tysm
yw
I said it first this time
ok mr smartiepants
horribly
nawww
what even is this
*smarty
well no, you gave him the solution lol
in this way he will never learn
same thing
and he need to learn cuz he is really bad xD
and me ๐ถโโ๏ธ

he doesn't appreciate me
this is my 2nd day coding
why you doing dpy then
thats nice
Thats good keep up
i like it
keep it up
recommended you do python first
@slate swan ty
anytime
You should start learning the basic first, you can't develop a dpy bot without even know what a class is lol
bro
Discord bot dev isn't like one of the first things you do when starting to code.
yeah
you should learn first you kinda bad a kwargs and others
bro I just did help_command=None
you did bot = commands.Bot(command_prefix=";", help_command=None)
you shouldve said its a kwarg
its a kwarg in the bot constructor
and did you?
he doesn't even know what a kwarg is I think ๐
scroll
you didn't even issue PEP8
welp
shit
why would i?
because
you should
bro ๐ญ
go to sleep lmfao
night
bye
Guys, just a little off topic, but not that much:
If somebody offers you a job paid by the hour, make sure that the job is a software in assembly language
D_D
lol
im eating
idgaf
_>
next time someone asks a question I'll lay out the solution as a stack overflow answer
with lots of juicy detail
ok?
i swear if you lay a 10 year old solution im going to come to your house
already know it
and I'll also buy you the plane ticket
gn
i love u all sm for helping me, i appreciate it
anytime! thats why this channel is for
how do i make a command that will repeat what a member says?
example:
MEMBER: ;say hello whatโs up
BOT: hello whatโs up
you can use a kwarg to eat all the text
me having no idea what a kwag is: 
@bot.command()
async def say(ctx,*,rep):
await ctx.send(rep)
ty
that should work
Btw ppl can do ;say https://discord.gg/ ..and the bot going to send the discord invite
well you can just check the content
U can do @shrewd inlet
#ur code```
what code ?
this is a good example
@bot.command()
async def say(ctx,*,rep):
if "discord.gg/" in rep:
await ctx.send("cannot say that")
else:
await ctx.send(rep)
I meant u can replace "#ur code" with await ctx.send("invites are bad") stuff like these
you can check a list if you wanted to
Well he should do that
๐คท๐พ So he can learn py
anyways gn yall
huh?

I will use poki instead of point from now on
I'm trying to make a poki here
i put that and it says [pyflakes] expected an indented block
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
you have to use indentation in python to signal what line of code falls inside a block
edited the msg to btw
ty
yw
and i can also do it with @\everyone and @\here right?
yes
but everyone will just annoy everyone
if you dont want some words to repeat just check a list
using in to check for things like discord links in strings isnโt really that good btw. Consider using regex.
why exactly?
Because regex was built for this task alone.
true
but it works
whatever works, works ๐คท๐ปโโ๏ธ
i have a weird issue regarding my discord moderation bot
mod bots have dashboards that let you set punishments for certain offences
and my bot's warn system is based on warn points rather than "normal" warns
but its possible to make an offence so that it punishes you but doesnt directly give you warn points
like, have it automatically mute, kick, or temp ban
you could read the user message
was that replying to me
but what if for example, a server sets the kick threshold at 20 points and ban threshold at 40
and someone sends a message with stuff so that the punishment would be "auto kick"
and they are at 39 points
you have to set a cooldown for that points tho
wdym
after 5 minutes or 10, you must -1 their warning point
why would you periodically remove someones infractions
your bot will ban them
like, how do i give the warning points in such a case
cus 40 chances isnt enough 
Make 2 point system I guess?
in this case they committed an offence that doesnt directly give warn points as punishment tho...
but it auto mutes/kicks/bans
then don't add warn point to them
for mutes that might work but for kicks and tempbans that doesnt really make sense imo
anyone that can help me how to make the text to a url?
would having other kick/ban thresholds based on how many times you have been muted/kicked/tempbanned be a good idea
inside quotes lol
wdym?
has to be a str
thanks
Is it possible to get the bots role color and avatar for the thumbnail in an embed?
!d discord.ext.commands.Bot.user.avatar.url
No documentation found for the requested symbol.
embed = discord.Embed(..., color = ctx.me.colour)
embed.set_thumbnail(url=ctx.me.display_avatar.url)
Eh?
Yeah so how would I get the bots role color?
nothing, the first is just neater
Yeah i thought so since its an obj sorry for the useless ping
It save up some lines though btw, I dont really care about pings tbh
Yeah since its an obj you set an img or smth and it makes it more tiny and alr its just some people like kayle dont like it and i forget to turn off the ping on replies
how do i make an embed autoresponder command
like for example:
MEMBER: ;help
BOT: (the embed)
is there any way to timeout a member/user object?
because the discord app provides it
ping me if you have an answer
Disnake /pycord have added it
oh nice!
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
Already made a command for it lol
I mean you can just use timeouts lol
I'd prefer a mute command rather than the timeout
I'm confused
Great
Timeouts max is 28days i think
1 week in the discord ui
Just make a command or sub class the help command
what
Supports up to 28 days in the future. May not be used in combination with theย untilย parameter.
I see
!d discord.Embed use this to construct the embed , discord.py already gives you a help command , you can either remove that and create a new one
Or you can override the default help by subclassing it
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.
oh ya i deleted the help command
hey anyone know what values the duration param takes in member.timeout()?
Takes floats
does it take floats? and if so is it days, seconds, minutes or what?
just looks at the source code jeez
idk where to find it
Parameters
durationย (Optional[Union[float,ย datetime.timedelta]]) โ The duration (seconds or timedelta) of the memberโs timeout. Set toย Noneย to remove the timeout. Supports up to 28 days in the future. May not be used in combination with theย untilย parameter.
untilย (Optional[datetime.datetime]) โ The expiry date/time of the memberโs timeout. Set toย Noneย to remove the timeout. Supports up to 28 days in the future. May not be used in combination with theย durationย parameter.
reasonย (Optional[str]) โ The reason for this timeout. Appears on the audit log.
You can only use one kwarg btw
ok
Read docs for the explanation
ok
^
*two kwargs
the reason can always be supplied
ah, wrong reply
meant to reply to this
you can use either duration or until, but not both
and reason
Thats what im saying lol
so that's 2 kwargs that you can always use
just not 3
and actually we should typehint that with overloads
I never said how much you could use
Theres 3 but you can only use 2
ye
lol
Why does it give me this error? File "C:\Users\shake\AppData\Local\Programs\Python\bot.py", line 507 await member.timeout(duration=duration, *, reason=reason) ^^^^^^^^^^^^^^^^^ SyntaxError: iterable argument unpacking follows keyword argument unpacking
duration = (time * 60)```
so why did i get that error? (time is a param that is in minutes)
you dont need the *
Your making a kwarg a kwarg lol
ah i added the * in the wrong spot :/
Yeah it should be in params
uh huh lol
Lol
oh k then
Yeah
so i just ran the timeout command, it says that Member has no attr timeout, even tho im using disnake
weird mind ending the command
i did
here is the code ```py
@client.command()
@commands.has_permissions(manage_messages=True, kick_members=True, ban_members=True)
async def timeout(ctx, member: discord.Member, time: float, *, reason='None'):
duration = (time * 60)
await member.timeout(duration=duration, reason=reason)
try:
await member.send(f'''{member.mention} you were put in the timeout chair by {ctx.author} for {time} minutes, because:
{reason}.''')
except (discord.HTTPException, discord.errors.HTTPException, discord.ext.commands.errors.CommandInvokeError,
commands.CommandInvokeError, commands.CommandError, AttributeError, discord.Forbidden):
print(f'Cannot direct message {member.name}.')
await ctx.send(f'''{ctx.author.mention} was put {member.mention} in the timeout chair for {time} minutes, because:
{reason}.''')
i read member as a member object, should i have fetched the member using the id instead?
idk all seems good
okay guess im going to delete these commands
did you import disnake as discord?
weird dont tho wait for someone who knows
alr
im not going to push this onto github tho lol
in params make time have a default value of None so if not given it will unmute them
async def timeout(ctx, member: discord.Member, time: float = None, *, reason='None'):
okay
relatable
?
what?
help
so, essentially, i wanted to do member.timeout() in disnake, but it says that Member object doesn't have attr called 'timeout'
even tho i imported disnake
Did u update disnake?
py -u pip install disnake in cmdline or not?
No
hm, then what?
py pip install -U disnake ?
Yea
py -m pip install -U disnake
weird i get no errors
@bot.command(aliases=["mute", "mutemember"])
@commands.has_permissions(ban_members=True)
async def timeout(ctx,member: disnake.Member,time=None,*,reason=None):
await member.timeout(duration=time,reason=reason)
Weird no
@quaint epoch btw dont typehint duration as a float so users can use duration as a datetime delta obj
oh nvm
That should update to 2.3
alr
okay i got 2.3
lemme see if it works now
!e
from datetime import datetime
time = datetime.utcnow()
print(float(time))
Hmmmmmmm okay
imagine using slash commands
im waiting till the week before it changes
it will be least fucked then
its all cancer rn
nice it worked
they seem useful but idk why i should change all my commands to slash commands
soon dislash will win
Staff on holiday from this Friday to 3rd Jan
yeah that
Thought u meant discord changing stuff
no
disnake will win soon and then pycord devs will contribute to it
its too split rn
we need daddy disnake to dominate
fuck pycord | nextcord | all that shit
what
would cause time to be str wouldn't it? As in discord.py parameters without annotations are internally casted to str
And if you were to typehint it as a float you can just do datetime.datetime.utcnow() + datetime.timedelta(seconds=time)
Ah i see my fault
How do you not get any errors btw from your code

idrk
can you run that code again but print type(time)
i type hinted it to a float lol
to lazy to do it
i didnt even tested it out i just pushed it to git lol
So is the example you sent not the current one
no it was i just edited it
I'm so confused
nvm lol
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\bruh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Usuario\Desktop\Hehe.py", line 12, in on_message
if message.content.lowet().startswith('>teste'):
AttributeError: 'str' object has no attribute 'lowet'```
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('hello?')
@client.event
async def on_message(message):
if message.content.lowet().startswith('>teste'):
await client.send_message(message.channel, "Oi")
client.run('bruh')```
How to resolve this?
And don't use Client for commands 
Yea that too
Outdated code
bruh
client.send_message is no longer a thing
Yea
i writed it
message.channel.send
i viewed 2017 tutorial

That would make sense why heโs using Client
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Yea
The commands framework didnโt exists that far back
Mhm
ahn
new traceback
Traceback (most recent call last):
File "C:\Users\dies from cringe\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\fardnuks\Desktop\Hehe.py", line 13, in on_message
await message.channel.send(message.channel, "Oi")
TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given```
remove message.channel from there
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('hello?')
@client.event
async def on_message(message):
if message.content.lower().startswith('>fard'):
await message.channel.send(message.channel, "*farding")
client.run('fardingfardamogus')```
wrote*
wrote ๐
viewed a*
;-;
works!11
I have a list of channel ids and i want to make it a list of channel objects do i use for loop or list comprehension. py channels = [for channel in self.bot.config['tutorial']['channels'] ]this is what i got for list comp and i sont know what to do next
you can just do
saving the channel ids in self.bot.config['tutorial']['channels'] py channels = [self.bot.get_channel(channel_id) for channel_id in self.bot.config['tutorial']['channels'] ]
list comps are faster than for loops so i suggest list comps
how to create a message variantion
example, i say >crime,
and i can put random money number?
!d random.randint
random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
you can use a f string
!e py import random print(f'the random number is {random.randint(1,10)}')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
the random number is 2
no worries ;)
XDXD 
a better way to make commands is the Bot framework though
you would just have to make functions instead of lots of if/elif commands in an on_message event
randint need
import random.randint
not slash , normal message commands
ok
it would be py from random import randint
ur something
yez
import discord
import asyncio
from random import randint
import random
client = discord.Client()
@client.event
async def on_ready():
print('Logged!')
@client.event
async def on_message(message):
if message.content.lower().startswith('!steal'):
await message.channel.send(f'You have {random.radiant(1,5000)}')
client.run('...')```
i typing !steal, and i dont recive the message
is that all the code you have?
yes
from random import randint remove this since youre importing random
ready
traceback
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\whoareyou\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\whereyouare\Desktop\Hehehahihou.py", line 14, in on_message
await message.channel.send(f'You have {random.radiant(1,5000)}')
AttributeError: module 'random' has no attribute 'radiant'```
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...
no
clean chat = delete all chat messages
you'd keep purging all the messages in the channel for that
how do i get input from user like
yes or no
!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**...
how do i use it
msg = await client.wait_for('message', check=lambda message: message.author == ctx.author)
returns a message object, to get the content just use msg.content, will be a str
async def your_command .......>
message = await bot.wait_for('message')
# message is the response ```
thanks
you can also set your check to a bool returning function if you prefer, making sure msg.content.lower() in ["yes", "no"] to require specific response
Any reason?
The only one I could think of is that it would be immutable, but I don't see now that would give much of an advantage here
how do i make an embed command?
Wdym
like for example:
MEMBER: ;help
BOT: (the 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.
Thanks
Youll have to make a embed obj and then you can send the embed with the embe kwarg in .send
i learn from this hope it helps u
we can only make cd with bucket?
cuz everytime i restart the bot the cd refresh
print("its about the rice its about the flour")
?
๐คฃ
what is this
certified hood classic
wth does "type" do?
did you want me to laugh?
Idk never seen it or tried it
interesting
Ikr
cool
me too
sleep
btw
.
@upbeat otter this what docs say idk what it means tho
type
The type of embed. Usually โrichโ. This can be set during initialisation. Possible strings for embed types can be found on discordโsย api docs
Type
str
Who?
ohk fine
Lol
I pinged you so you
hmm
No need for sleep
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
Devs dont sleep
Good play
Iโm not sure but I think another type is when u send a link discord will automatically send a preview
help ;-;
there's always time for everything if you know how to use it wisely
mhm
lmao
Stop being off topic guys
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
Stop
stop spamming
Stop harrasing others
=.=
Dont ping me
ok :D
;-; what did I do
Ok im gonna stop now
Im bored sorry
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
lol
guys whatโs the best way to show a help embed
๐ด๏ธ
:/ there is only one way
sending it?
as an embed
Ig subclassing the help command
Thats a embed lol
add color
iโm talking ab the description like is it good
Use bold text
i like a clean embed
this is how mine looks like
ooo
let user's customise the embed color :')
i like that
100% copy
added it recently
how do u do that ๐ญ
With the color kwarg
we can only make cd with bucket?
cuz everytime i restart the bot the cd refresh
!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.
^
HELP
databases
we can only make cd with bucket?
cuz everytime i restart the bot the cd refresh
I mean ofc it will restart
so how do i make it continues
is there other ways?
just don't restart very often
ok
is ; a good prefix or should i choose another one?
then imma just ignore that
Smart human
good for pc not for phone
Prefix really doesnt matter
it's honestly just preferences
All personal preference
as a default sure, but allow a per-guild prefix option
. / > is my fav one
now how can i do that ๐ญ
dbs
my fav is ,
get_prefix()
My fav is period
ummm pls help me
it's called every time there's a message so it's worth keeping that in mind
i wanna make it so other people from other servers can change their prefix
Other bot devs i've talked to said they use caching to hold prefixes as making a database call every single message can get stressful on the database
especially because their bot was pretty big
But you don't really have to worry about that until later
get_prefix( bot , message ):
# do something to get the custom prefix
return prefix
bot = commands.Bot(command_prefix=get_prefix)```
ty
notice how it takes a message parameter
that's what i meant by it gets called every message
you can use the message and bot params
usually people hook it up to a database to store and retrieve prefixes
so letโs say i could make it so if they say ;prefix ? it would change to that prefix ?
you would need a command for that
You would have to make command for that
that would edit the database entry
I don't think they have a database yet? Correct me if I'm wrong @shrewd inlet
def get_prefix(bot, message):
# get prefix from database
return prefix
@bot.command()
async def prefix(ctx, prefix):
# set the prefix in the database
Nah they don't
i donโt
how do i get a database
yeah so you're gonna have to make one
how ๐
i-
personally i would say sqlite is the easiest but it's limited in features unlike postgres
yk what iโll just make people stick to my prefix ๐
lmao
go for sqlite if u have no experience with dbs
^
lmao sure
i found sqlite very easy
same
iโll keep this in mind
mongodb is more of a json sort of database if you wanna do that as well
though personally i find relational databases easier for modelling user data on discord
mongodb sounds funny
it does xd
Anything with sql is pretty easy
mangodb
literally, standard query language
especially for discord-related data
structured*?
An you can use aiosqlite for async libs
yep
if you don't want to make things complicated by making a database server etc just use Sqlite
Yeah
It's ok for a small/medium sized bot
yes mb
and if you don't put too much load on the db ( just like the cache thing we talked earlier ) it can be used in big projects too
transferring the data to a more flexible and scalable database later on will be an absolute headache i assume
right if you add an intermediate caching database like redis you should be okay for a long while
how can i add an image to an embed command
local or url?
url
embed.set_image then
or both idc
.set_thumbnail()
or .set_image()
pretty sure thumbnail is the tiny one on the right
image is the big one on the bottom
yep, thumbnail is smaller
@shrewd inlet i mostly use
-> https://sqlbolt.com/
To learn sql havent learned it much because im lazy but its really easy and you can alwayd use aiosqlite for async libs
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
!pypi aiosqlite
asqlite also works, as a bonus it's by the same person who made discord.py and has better defaults
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
I learn from another dev lol
I means yes but aiosqlite is more maintained
for sure yeah
ok so for the image can i set the name of the random images i got
Lol
like i have a series of random images
You can migrate to pgsql tho
so how do i do that ?
oh cool, didn't know that existed
can you elaborate?
embeds only show the image, not the name of the image
Hi
yeah i want the image not the name of it
yea it's not published on PyPi yet iirc ,
Developed by one of hikari library developers
so you want to send a random iamge
Can someone help me build a bot


so i basically have this and i want to include it in the embed command
Use the random module and do as said
@bot.command()
async def pic(ctx):
embed = discord.Embed(description="here's your random image!",color=0x2f3136)
embed.set_image(random.choice(gracie_images))
did i do it right?
you got it
Yes
don't forget to import random
on discord
i did
what's the error
did u send the embed?
doesn't set_image take a url= kwarg or am i dumb
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_image() takes 1 positional argument but 2 were given
172.18.0.1 - - [23/Dec/2021 06:21:42] "HEAD / HTTP/1.1" 200 -
thought so
yeah
pass in a url= kwarg into .set_image() and you should be good to go
also import random
how?
.set_image(url="my_url")
but itโs a random image
right
so how am i gonna do that
use random.choice
url=random.choice(gracie_images)```
would look something like this
yep and put that in the .set_image
error?
nope
@bot.command()
async def pic(ctx):
embed = discord.Embed(description="here's your random image!",color=0x2f3136)
embed.set_image(url=random.choice(gracie_images))

every argument in the Embed class are keyword arguments
that's ur whole command?
ya
ah
if so, u didn't send the embed
o
Now your yellow