#discord-bots
1 messages ยท Page 875 of 1
it doesn't have help?
so, how do i add that variable 'help' to my command
help
install it first
pip install discord.py
yes
oh cool
where is it
left tab
wht should i search
version1.7.3?
yes
i didnt know it was that easy ๐ , ive been looking this shit up for hours ๐
yes
if i learn how to make discord bots will it also give me a base in python
usually when you import a package and run, replit automatically installs that package
maybe
it all depends on you though
but sometimes, you need a base in python to make bots
okay thx
now pls I want someone to tell me how can I host my bot for free 24/7 ?
I don't know anything about hosting so if anyone answers pls answer in a beginner friendly method pls
Are you willing to pay?
So then ?
you can try self hosting
How pls tell ?
get a spare pc/laptop and keep it on with the script running
I have only one laptop
:/
a good hosting server is what I want
for free
As mmy bot has the main purpose to welcom on join
nvm
@client.command()
async def bruh(ctx):
button = discord.ui.Button(label="Hi", style=discord.ButtonStyle.green)
view = discord.ui.View
view.add_item(item=button)
await ctx.send(Hi, view=view)
Command raised an exception: TypeError: add_item() missing 1 required positional argument: 'self'
e = []
for n in range(len(item_name)):
i = item_name[n]
e.append((item_name[i], item_emoji[i], database.check_item(name, i)))
aeeee = map(e)
print(aeeee)``` TypeError: list indices must be integers or slices, not str `holy duck`
@stray carbon fixed that?
seems like i is a str
fixed that, now TypeError: map() must have at least two arguments., i hate
!d map
map(function, iterable, ...)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterable* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3/library/itertools.html#itertools.starmap "itertools.starmap").
it takes a function and an iterable
๐ฟ now what function
wot
a doubt. are there button creators, like this one https://cog-creators.github.io/discord-embed-sandbox/
in my code?
random.choice(responses) not response
kk
yup
Guys do you know any free vps through which i can host my discord bot. The vps should be free and shouldnt ask for any payment verification
I was reading abt interactions ๐
nope
nice
the one company that had free hosting removed it
nice
cause they were facing losses
so i guess i have to stick to replit
although you could try railway.app maybe
ok
nah thats worse
anybody?
no
embeds are easy to make, why would you need a "creator" for one?
save code length
A lambda or a predefined function
!e
print(list(map(lambda x: x * x, [x for x in range(10)])))
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
or you can just save 30 bytes with list comp
azure's free tier
only applies if you're a student and have a school-issued email id
What applies?
The free tier
You can apply for azure's free tier if you meet those criteria, that's all
Also can someone remind me how to convert datetime.now into a format that can be used by the markdown timestamps
!d datetime.datetime.timestamp
datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").
Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.
For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:
```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
``` New in version 3.3.
Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
Got it thanks
e = []
for n in range(len(item_name)):
nyeh = item_name[n]
e.append((item_name[n], item_emoji[nyeh], database.check_item(name, nyeh)))
aeeee = map(lambda x: f"\n{x[1]} {x[0]}: {str(x[2])}", e)
qq = list(aeeee)
i.add_field(name="--ingredients--", value=qq[2]+qq[3]+qq[4]+qq[6]+qq[9]+qq[11]+qq[15]+qq[21]+qq[22]+qq[24])
i.add_field(name="--items--", value=qq[5]+qq[7]+qq[8]+qq[10]+qq[12]+qq[13]+qq[14]+qq[23]+qq[25]+qq[37])
i.add_field(name="--boost--", value=qq[35]+qq[36])
i.add_field(name="--potion--", value=qq[16]+qq[17]+qq[18]+qq[19]+qq[20])
i.add_field(name="--minerals--", value=qq[26]+qq[27]+qq[28]+qq[29]+qq[30]+qq[31]+qq[32]+qq[33]+qq[34])
i.add_field(name="--sacred items--", value=qq[0]+qq[1])
await ctx.channel.send(embed=i)``` i want so when item count is 0, it wont add the item to items list in my inventory, any best way?
idk what programming language youre trying to do but that ainโt this one
wut
snipe_message_author = {}
snipe_message_content = {}
snipe_author_avatar = {}
message_deleted_at = {}
@client.event
async def on_message_delete(message):
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
snipe_author_avatar[message.channel.id] = message.author.avatar_url
message_deleted_at[message.channel.id] = int(time.time())
in on_message_delete
snipe_author_avatar[message.channel.id] = message.author.avatar_url
AttributeError: 'Member' object has no attribute 'avatar_url
try member.avatar.url
display_avatar
message.author.display_avatar?
both work
ok
yee
ig for the updated no
avatar_url?
Hey peeps do any one know how to make like this?
not for embeds, for buttons
like what
avatar_url is <=1.7 and in beta its avatar and display_avatar
set_author
!d discord.Embed.set_author
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.mention}", value="โ
Verified 18+โ
", inline=False)
embed.add_field(name='Name', value=str(ctx.author.name), inline=True)
await ctx.send("What Is Your Name?")
msg = await client.wait_for('message')
await ctx.send("What Is Your Name?")
msg = await client.wait_for('message')
await ctx.send(embed=embed)
print(f"The embed has been send")```
set_author
@jade tartan
embed=discord.Embed.set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)
Right?
nvm i got it
discord.ui doesnt exist?!?
Install 2.0
it got the author name but not the author profile image
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.mention}", value="โ
Verified 18+โ
", inline=False)
embed.add_field(name='Name', value=str(ctx.author.name), inline=True)
embed.set_author(name=ctx.author.display_name, url=embed.Empty, icon_url=embed.Empty)
await ctx.send("What Is Your Name?")
msg = await client.wait_for('message')
await ctx.send("What Is Your Name?")
msg = await client.wait_for('message')
await ctx.send(embed=embed)
print(f"The embed has been send")```
pip install git+https://GitHub.com/Rapptz/discord.py
@client.command()
async def bruh(ctx):
button = discord.ui.Button(label='Click')
view = discord.ui.View()
view.add_item(item=button)
await ctx.send('Hi', view=view)
i want the the bot to send message "Hi" when someone clicks button
yeah because icon_url is set to embed.Empty. If you have empty stuff, you dont need to put the argument
!d discord.Embed.set_author
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
U need to subclass View
you probably should make an ACTUAL class view
So just leave it empty?
class SomeView(discord.ui.View):
def __init__(self, ...) -> None:
...
# components here
its set to empty by default, so no need to be explicit with it
embed.set_author(name=ctx.author.display_name, url=embed.Empty, icon_url="") Like this?
no like remove the whole arg if you aren't going to be setting it to anything
ohh ok
embed.set_author(name=ctx.author.display_name)
i got that one
(ik python zen says explicit is better than implicit, but setting args to what their default is explicitly ain't it)
well you have to set the author icon_url to something if you want something to show. I was just saying that if you aren't going to set it to anything, no need to specify it
Its a dsicord bot, but its a python problem, idk where to send it in...
async def war(ctx, hour=None, day=None):
time_obj = time.localtime()
local_time = time.strftime("%a %b %d %H:00:00 %Y", time_obj) # Year, Month, day, hour
time_sting = time.strptime(local_time)
time_tuple = (0, 0, day, hour, 0, 0, 0, 0, 0)
war_time = str(time.mktime(time_sting + time_tuple)).split(".")[0]
await ctx.channel.send("<t:" + war_time + ":F>" + " <t:" + war_time + ":R>" )
its gives me the error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: mktime(): illegal time tuple argument
I dont know how to fix it, and already searched about it on google... can anoyne help me?
!d time.mktime
time.mktime(t)```
This is the inverse function of [`localtime()`](https://docs.python.org/3/library/time.html#time.localtime "time.localtime"). Its argument is the [`struct_time`](https://docs.python.org/3/library/time.html#time.struct_time "time.struct_time") or full 9-tuple (since the dst flag is needed; use `-1` as the dst flag if it is unknown) which expresses the time in *local* time, not UTC. It returns a floating point number, for compatibility with [`time()`](https://docs.python.org/3/library/time.html#time.time "time.time"). If the input value cannot be represented as a valid time, either [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") will be raised (which depends on whether the invalid value is caught by Python or the underlying C libraries). The earliest date for which it can generate a time is platform-dependent.
seems like the function doesn't accept tuples as an argument
What do i set it to make it have that?
effectively what you've done is:
str(time.mktime(time.strptime(local_time) + (0, 0, day, hour, 0, 0, 0, 0, 0))).split(".")[0]
oh no
first off, cogs are supposed to be in a separate file
its __init__ not _init_
you are missing :'s and indentation is horrendous
mb its my first day tryna code
icon_url=ctx.message.author.avatar_url?
same error :/
yeah, not a good idea to do a discord bot day 1. please learn the language first
okayyyy
i wasn't saying to put that. i was just showing you what you've done with that function call
how do i learn the lang
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
oh ok sry...
but how do i add time than?
@bleak flower it seems time.mktime doesn't take the two arguments you supplied it, especially the tuple argument
try removing the tuple argument and see what happens
i dont understand wht it does its just showing me something like filters and all wht should i do to get started
I have one more question but let just try this
ik it won't work, but I want to see the error
filter based on beginner and what type of source you want to learn from
i highly recommend Automate the Boring Stuff
Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
async def war(ctx, hour=None, day=None):
time_obj = time.localtime()
local_time = time.strftime("%a %b %d %H:00:00 %Y", time_obj) # Year, Month, day, hour
time_sting = time.strptime(local_time)
time_tuple = (0, 0, day, hour, 0, 0, 0, 0, 0)
war_time = str(time.mktime(time_sting)).split(".")[0]
await ctx.channel.send("<t:" + war_time + ":F>" + " <t:" + war_time + ":R>" )
like this? this works
it works?
yes
does it give the outcome you wanted
@slim ibex it doesnt work
it gives the outcome the i want to get with the code, but i cant add time to it, which i want
Damn
wdym add time
Ok
the time at the moment + the time given in the command
you can get current time (time command was executed) with datetime.datetime.utcnow iirc
i'm not sure about the time in the command part
its a book tht teachs me how to code rght
this piece of code returns a runtime error
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
but i checked again and again
i didnt forget await anywhere
@slim ibex sorry for ping but im fumbling
Pls help me in hosting my bot 24x7
I made it in Atom text editor
Pls ping if anyone answes
moai, please
@bot.command('report')
async def report(ctx):
'''
Report the current trending game to the online moderators, you can choose to whom should you report
'''
blacklisted_ppl = open('blacklist.txt', 'r')
ppl = blacklisted_ppl.readlines()
print(ctx.author.id)
for i in ppl:
if str(ctx.author.id) == i:
embed=discord.Embed(title="Action denied", description="You cannot run the ??report command as you are blacklisted from using this command", color=0xd31212)
await ctx.send(embed=embed)
return
file = open('database.txt', 'r')
game = file.read()
mods = discord.utils.get(ctx.guild.roles, name = "๐๏ธ๏ธฑModeration Team")
members = mods.members
id = list(map(lambda m: m.id, members))
print(id)
for i in id:
user = await bot.fetch_user(i)
if str(user.status) == 'online' or str(user.status) == 'dnd':
button = Button(label = user.name, style=discord.ButtonStyle.green)
biew = View()
biew.add_item(button)
await ctx.send('Select an online member', view = biew)
I want to host it for free
not gonna happen if you want reliable, 24/7 hosting
sad
vultr is pretty much "free" though. its like $5 a month or maybe even lower
they charge by the second
first my command checks if the user is blacklisted, then it gets all the ppl with the "mod" role then i get their names and then i proceed to make a button for each online moderator
@bot.command(name="report")
is that it
that wont fix but thats a syntax error
is there any specific line the traceback says?
ive read that a million times ๐ข
no ๐ข
print(id) prints coroutine object Command.call at 0x00000189D4634200>
U didn't await smth
ik but i checked a million times
Code
hey how can i get the uptime of the bot?
here is that full command
oh wait
Just store the startup time in a botvar, and when the command is ran, minus it from the current time
oh okay
thanks
!botvar if u need help with botvars
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
btw, this is a rudimentary version soo dont make fun of me ;-;
People gonna make more fun of u if u don't use code blocks
lemme check
well, it returns a coro
ikr
see
its a coroutine
i'm just going on a whim. it might not be it
Ah cool
it used to print ```
Ready!
813058518625157180
<coroutine object Command.call at 0x0000022ABC1758C0>
and then raise the exception
now its just ```
Ready!
813058518625157180
and it doesnt return an error, nor does it do smth
Ayyy GJ @slim ibex
lol i think its fixed
yeah lol
it doesnt do anything
@jolly basalt whats the issue tho
well atleast the error is fixed
its saying, i forgot await somewhere
now it doesnt say that
the issue is fixed
yeah because you awaited that coroutine object
ty moai
lol yeah, i was confused so i printed it
btw for your open()'s, use context manager so the file is closed after, and pls dont use .txt files as a database
anyways im off for the night.
yeah, i wont
its morning, wake up
this is a rudimentary version
goodnight
not something, coroutines are awaited 
Morning for you, post noon for others
๐๐๐

U check for JSONDecodeError
how to run aiohttp TCP site with discord bot in a cog?
Web stuff not my area of expertise

Then u can help him (:
Out of curiosity, what happens to Member.mention if the user has left the server?
The ping is shown as this:
That looks like an id
invalid-user
Not for me, it's an invalid user ping for me
please avoid using emojis like these
Nvm, discord broke
ok, cool, thanks
Anyways, I just wanna tell the ping changes to @invalid-user
dammit wrong server
yes, it is a problem, i dont want to annoy ya'll ;-;
Felt like a bot/code problem
ive been asking too much doubts lol
Haha okay
U using disnake, right?
Mind showing the whole traceback?
Nothing more?
Weird... Is the command showing any options in the GUI?
alright
According to the code, there ain't, but according to the error, there are lmao
"Application command interaction options values"
U on the latest disnake version?
got it
Weird, try asking in the disnake server
don't crosspost I'd say
<coroutine object Command.call at 0x0000015156FBF840>
Lonely, he's asking help from different guilds
i need to know why this happened, i not only need a solution, i need to find why it does that
idk why you'd give multiple people looking for the same problem
this has worked multiple times before, why does this show just in this cmd
he isn't even showing errors or where he prints, this is just funny at this point
this has nothing to do with the lines you showed us
want proof? comment out the lines and you'll get the exact same result
your "issue" isn't coming from the lines you think it is
you're not giving is any context
bruh
what im trying to do with this snippet is to get all the id's of members with a specific role
usually when you do that, you get the ids
!d discord.Role.members
property members: List[Member]```
Returns all the members with this role.
use a list comprehension, easy stuff
yeah, when i posted this exact thing on the discord.py server, all they do is say something else that doesnt work
.
those are also easy to make?
what're you trying to do?
.
he just needs the ids of all members with that role
I already gave you the solution in the other guild, but yeah...
@jolly basalt
well, idk, I prefer list comps more than lambda
^
thats guild
"doesn't work" is VERY vague
it's mods.members instead of guild.members ofc
I just gave a similar example so you wouldn't copy paste and COMPREHEND
role_obj = discord.utils.get()
members_list = [member.id for member in role_obj.members]
bruh
why are you saying bruh?
How can i turn off the guild community using a bot?
@jolly basalt try this?
isnt that the same thing
nope
its a lot different
you were using a Guild object whereas that contains a Role object
yeah that should work
@jolly basalt does the role have members?
lmao
How can i turn off the guild community using a bot?
it does, i checked
bruh im restarting
Do you even have members intent
press x for doubt
Dev portal
yeah ofc
What if you print mods.members
you're using bot AND client...?
bruh i dont use that
then remove it
that's the worse format i seen ๐
i just forgot to remove it
if you print guild.members in a command, does it give a correct list?
aight, and you're positive some members actually do have the role?
alright, is this a guild specific command?
so you'll have multiple guilds with the EXACT same role name?
i didnt get the question sooo. this is a bot just in one server
my head is burning, im taking a nap
fuck discord
I took a moment to process that there are people who still do that.
i just forgot to remove it
role names are lowercase, your "mods" role might be None
It would then raise an error NoneType has no attribute 'members'.
Why not use guild.get_role(role_id) instead?
ill put that in my checklist, im gonna go take a nap, cuz this shouldnt happen
While it wouldn't make a great difference, but it'd be a bit more exact I think?
he wants to use it in multiple guilds
no
well, you said so
How can i turn off the guild community using a bot?
does anyone know the command in python to add emoji and remove
How can i turn off the guild community using a bot?
idt you can
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
I'm unsure if you can do it with dpy, but you can with disnake.
!d disnake.Guild.edit
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., region=..., afk_channel=..., owner=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the guild.
You must have [`manage_guild`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_guild "disnake.Permissions.manage_guild") permission to use this.
Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.
Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.
Changed in version 2.0: The newly updated guild is returned.
Wait this can change ownership
How does 2fa work then for that
Only if the bot has the ownership.
Bot accounts don't have 2FA afaik.
The new owner of the guild to transfer ownership to. Note that you must be owner of the guild to do this
2fa should raise forbidden then
You did not restart your code after you changed it?
i restarted my wholw computer
i was messing with path n' stuff, maybe its that, idk
scoopy long time no see
from discord.ext import commands
# -------------------- Cogs --------------------
class admin(commands.Cog):
def __init__(self, client):
self.client = client
# -------------------- Launch --------------------
@commands.Cog.listener()
async def on_ready(self):
print('Loaded Admin Commands')
# -------------------- Ban Command --------------------
@commands.Cog.listener()
async def ban(ctx, message, member, *, reason = None):
await member.ban(reason = reason)
await message.reply(f"Banned {member}")
# -------------------- Cogs Setup --------------------
def setup(client):
client.add_cog(admin(client))
why this isn't working?
ping me
ban command has an event decorator
how can i fix it
firstly
you didn't pass self in the "command"
it's inside a cog, pass self
second, the decorator is @commands.command()
done
the one you used is for events
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'ban'
typehint member to discord.Member
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Admin_Commands' raised an error: NameError: name 'discord' is not defined
@quick gust
from discord.ext import commands
# -------------------- Cogs --------------------
class admin(commands.Cog):
def __init__(self, client):
self.client = client
# -------------------- Launch --------------------
@commands.Cog.listener()
async def on_ready(self):
print('Loaded Admin Commands')
# -------------------- Ban Command --------------------
@commands.command()
async def ban(self, message, ctx, member : discord.Member, *, reason = None):
await member.ban(reason = reason)
await message.reply(f"Banned {member}")
# -------------------- Cogs Setup --------------------
def setup(client):
client.add_cog(admin(client))
current code
you haven't imported discord
from discord.ext?
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
WHY IS IT SO HARD TO BAN A MEMBER
omfg
discord.ext.commands.errors.MemberNotFound: Member "test" not found.
@quick gust any ideas?
Bro?
?
async def ban(self, message, ctx, member : discord.Member, *, reason = None):
```Huh?
so what?
Wdym by message
message.reply...
...
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
Missing perms
error says it all
I swear it has Admin
you don't
I SWEAR!!!
No u dont
I DO
Code is not wrong
I HAVE THE SAME ROLE AS THE BOT
If the person you're trying to ban has admin too, it won't work
Wait
Makes sense
BUT THE ROLE IS HIGHER!

U can compare it with top_role
probably not true: try to ban someone without roles
<@&831776746206265384> change that fucking slowmode!
stop pinging them for no reason
Dont
!d discord.Member.top_role cof cof
property top_role: Role```
Returns the memberโs highest role.
This is useful for figuring where a member stands in the role hierarchy chain.
no, never
people have to think about what they type instead of typing 100 separate messages
bruh...
Huh ya this
What is the role of the person ur tryigng to ban
what isnt working though?
@stiff anvil
.....
What :'(
Nothing
Busy with irl stuff yk 
nice
Lol
๐ข

was it always 6 secs? nice
No they changed
Don't bully me <3
TF
nah it was 5 few days ago and 4 before that and 3 before that
excellent
Imagine after 2 years
and there was 0 once upon a time
!ot
dunno, wont be here
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.

rude

can't change Ash, won't change Ash
!ot thanks
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
same with Hunter

What u talking about? Idk the context of the convo
!rule 7 welcome
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
rile 
can't change Hunter, won't change Hunter
Goto ot tf

Imagine ghost ping
Everyone changes with time
Ghost ping prefix is ๐ป

๐ป return Hunter if python === js
I hate ghost pings 
Ghost pinged
Not self botting*
self-bot your acc
Get a ghost ping bot
Gonna do that once I get access to a better VPS
already have that made 
no
I mean thisnserver
imagine self-botting
Discord check ur account?
I did it once
imagine doing it
For sending all my friends a msg
Anyways imma stop
I'll take my leave 
The talk is still against ToS bruv
^this also discordbots
Whats your current vps specs
Not talking about specs, a friend is hosting my bot as a favor for now
Haha
You're the friend?
Good
Cause i was so confused why as fuck as why would they need more than that
th
Also flex
bro for what

do you host mee6
how good code to do??
What
really good
follow pep8


make code work code go boom

water you don't even dpy, you just pep8 
at least pep8 is better than dpy ๐

tho this is true 
internal error?
yeah?

{
"code":50035,
"errors":{
"data":{
"options":{
"_errors":[
{
"code":"INTERACTION_APPLICATION_COMMAND_OPTIONS_VALUE_INVALID",
"message":"Application command interaction option values must be of type string, integer, or boolean"
}
]
}
}
},
"message":"Invalid Form Body"
}
is this the error code?
ic
you really pulled the payload
https://github.com/discord/discord-api-docs/issues/2594
https://github.com/discord/discord-api-docs/issues/2596
try seeing any of those if you understand, am a deadass today 
@slate swan still the error isn't fixed?
bro if youre gonna import every class atleast import the Cog class๐
some internal issue ig?
Lmao
Yup, read the convo there too
Uhhh, I have an idea... try renaming the command and passing the guild_ids kwarg
Cog class not being imported and others being imported triggers me๐ฟ
Then don't look at the code
She means from disnake.ext.commands import Cog
import the Cog class pls๐ญ
Lmao
There's a strikethrough ๐
Still the same error?

discord.gg/discord-api try asking about the error in there
okimii stop confusing everyone for no valid reason
im not๐
Someone doesn't want oki to say anything ๐
shes mad im smort
Who says u r smart
im smort
!ot anyways
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
how?
Was there another cmd with the same name?
Or a function
Weird
Anyways what matters is that it's fixed
Uhh guys should i learn the basics of python first before i actually start a discord bot???
can i create a repos in Github without dwnlding anything? i.e in browser (website)
yess
Yes but using git is ideal
i use github desktop 
Windows desktop lmao
Imagine not Linux

shutdown is what you need to do rn๐
Imagine not talking about this in the ot channel ๐
๐ฟ
git means github desktop ?
github desktop is git with a ui
Tho github is a hub for many gits lmao
wat oof now i had to learn the basics of this ahhh
going to next class bye guys๐
Adios
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

adults :D
xd
ohh
i just want to host my bot 24x7
How u gonna do that with github tho
nothin els
idk some said first make a github repo i think i am misguided
aaaaaaaaaaa
!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.
ive also done it in discord.dev
you sus
idk are you :D
what the sus

im just a hairy 16 y/o, who is salty cuz he cant spend a minute without being smothered by problems in his code
I'm just a depressed and lonely 16 y/o ๐ฅด
;-;
anybody?
๐๏ธ ๐๐๏ธ
get_member(user_id, /)```
Returns a member with the given ID.
can you pls tell how do i host my bot 24x7 online ??
@maiden fable
U need to buy a VPS
Does using the async iterator for audit logs have high ratelimits?
Those are dynamic
what do you mean that?
They change with every request. The first request, it can be 4/2s and the next request, it can become 5/3s
still the same thing, im kinda thinking of giving up
What's the issue tho
yo guys can I put my variables into one file and import that file into another file with cogs
example:
file.py
x = 6
Y= 9
โclass test(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.command
async def ur_mom(self, ctx):
x + y
await ctx.send(โx plus yโ)โ
will the variable change in file.py?
from file import x, Y
it shows everyone is offline. i have intents added and enabled everywhere
okay cool so I want to go get the user who banned a member and im using on_member_ban so I should have no problems
that works? I thought that was only for classes
Try printing user.status
Nope lol
As long as u use events, u r good to go
i did and it prints this
u can import variables?
Show yr intents in code
By any chance do u have two bots defined?
nope ofc
Weird
what do you think would happen if there was a mass ban during raids? Currently for my on_member_ban i'm waiting one second before going through audit
#Ratelimited
No, it will only change locally in the other file
Wait, lemme see something
Sorry bruv. Try asking this in a help channel
!d discord.AsyncIterator
class discord.AsyncIterator```
Represents the โAsyncIteratorโ concept. Note that no such class exists, it is purely abstract.
async for x in y Iterates over the contents of the async iterator.
also how long would the ratelimit be if that were to happen?
Depends on the API
for free ?
even if you
import x, Y
in g.py?
No
aww man damnit i spent too much time for learning python and make a bot for my server then i cant host it
:(
have u tried guild.fetch_member
most vps have a free tire though
you will have to enter credit card details
some vps's like heroku dont require credit card details
how to make async typing function in nextcord slash command? anyone know?
async typing in slash command?
yes
Wym
to make the bot typing
like if we make google search command
it will take a moment for bot to search the query
and then it will display bot is typing...
It's the same like u do in text commands
it says "interaction has no attribute typing"
!d discord.ext.commands.Context.typing
async with typing()```
Returns a context manager that allows you to type for an indefinite period of time.
This is useful for denoting long computations in your bot.
Note
This is both a regular context manager and an async context manager. This means that both `with` and `async with` work with this.
Example Usage...
!d discord.TextChannel.typing
async with typing()```
Returns a context manager that allows you to type for an indefinite period of time.
This is useful for denoting long computations in your bot.
Note
This is both a regular context manager and an async context manager. This means that both `with` and `async with` work with this.
Example Usage...
Use this (:
so i use async with typing instead of async with interaction.typing?
async with interaction.channel.typing():
. . .
ooo okay thx
can you teach me how to host in heroku ?
iirc get is taking members from cache and fetch_members requests from discord
not too sure
Light Mode 
wtf... i love light mode...\
Don't use Heroku for hosting
so tell an alternative pls
Oh cool
Oracle free tier
hosting really isnt something you'd associate with free tbhj
U need a cc anyways
just buy a raspberry pi they're pretty cheap and decent
could you pls send the link of it
so what i can do i dont have money bruh
its legit like 30usd
Just use Oracle free tier...
Probably
i cant find a tutorial on yt on hosting a bot in oracle i dont know anything about it oof
Heroku is not recommended for a discord bot but if you really want to
https://www.youtube.com/watch?v=BPvg9bndP1U
so tell me what is recommended
free one
paid vps like digital ocean
no not paid man !!!!
have you hosted a bot ever in oracle ?
No
umm so how can you tell me how to do it
the recommended vps's are paid sadly....
oh no
alternatively you have a computer
just keep it on and host the bot on it
its free
There's probably a tutorial on their website on how to set it up
Hey @bleak flower!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
check if the author has a permission?
Rip battery 
can anyone tell why this doesn't work
if data[1] == None:
reason = 'No reason was specified'
else:
reason = str(data[1])
what is "data"?
the data[1] is None
async with bot.db.execute("SELECT member_id, reason, time, performing_user, bot FROM bans WHERE member_id = ?", (user.id,)) as cursor:
data = await cursor.fetchone()
I did print(data[1]) and it printed
its ok its a pc :)
embed = disnake.Embed(description=f'{user.name}#{user.discriminator } was banned at {time} by {action_taken_by} | {reason}', color=disnake.Color.blurple())
sorry I was going back and forth copying the revelant information and the slowmode doesn't help either
Indeed, but if it's a laptop (like in my case), then rip
why not use is and compare the objs id
i tried if data[1] is None: already same result
or if not
nah just a better way lmao
if reason is None then that block of code doesn't run
whats the type of data[1]
why not add a reason as a defualt value?
tuple
oh shoot
iirc columns return as a tuple
i got why nevermind
i was wondering if None was a string accidentally set or something
the NoneType? nah its set as the type and not a string
NoneType is a different class
whats with the space between the ending of user.discriminator
is this postgres asyncpg?
I don't think that ruins anything
idk
no
oh
Mistake but no affect
aiosqlite
you mean?
nothing, ignore me
class Config(commands.Cog):
"""Saves a config to the Deta database."""
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.slash_command(test_guilds=938194100639895713)
async def config(self, inter):
"""Presents the user with a config command"""
welcomeConfig = disnake.Embed(
title = "Welcome!",
description = "Welcome to the config menu. Each of the menu option will give you 30 seconds to reply. Let's start with the welcome channel."
).add_field(
name = "Welcome Channel",
value = "Please state the welcome channel ([#welcome](/guild/267624335836053506/channel/267631170882240512/) for example)"
)
announcementsConfig = disnake.Embed(
title = "Announcements",
description = "There is a /announce command which can be used by anyone with the specified admin role (set this later)"
).add_field(
name = "Announcement Channel",
value = "Please state the announcement channel ([#announcements](/guild/267624335836053506/channel/354619224620138496/) for example)")
await inter.response.send_message(embed = welcomeConfig)
def channelCheck(message: disnake.Message):
return message.author == message.author and message.channel == message.channel
return len(message.channel_mentions) > 0
welcome = await self.bot.wait_for("message", timeout=30.0, check=channelCheck)
await inter.channel.send(embed = announcementsConfig)
await self.bot.wait_for("message", timeout = 30.0, check = channelCheck)
So I need the message to only take #channels, but it doesn't :/ any help?
I am just lurking here and there
same
Lol
let me get one thing
return message.author == message.author and message.channel == message.channel
why
and this line
return len(message.channel_mentions) > 0
won't be reached
@client.listen()
async def on_message(message: discord.Message):
if 'heist' in message.content.lower():
if client.heistar == '':
return
else:
client.heistar
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'content' is not defined

do you use an other library now or just dpy 2.0?
dpy 2.0
then no idea
:/
but it says it was a command invoke error
so this can't be the code where the error occured

even tho
client.heistar
wouldn't do anything
idk
client.heistar = ''
@client.command()
@discord.ext.commands.has_permissions(manage_guild=True)
async def hara(ctx, *, Content: str):
if content == "":
await ctx.send("Message is an argument which is missing")
else:
client.heistar = Content
embed = discord.Embed(title = 'Heist Responder', description = f'**Reply**\n{Content}\n\n**Raw**\n\n`{Content}`\n')
await ctx.send(embed = embed)
yeah cuz None is the NoneType class
None is an instance of NoneType class
it was to make sure it's the person who called the slash who responds
or smth like that idk
yeah iirc
!e print(isinstance(None, NoneType))
@maiden fable :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'NoneType' is not defined
yeah well it doesn't make sure about nothing
๐
lol
How do I fix it lmao?
use None instead of ""
check if message.author == inter.author?
or inter.message.author, honestly no idea again
ok
doesnt really matter None is the NoneType class while an empty string is False it would be the same afaik
naming
you named your Content argument with a capital letter
then proceeded to use content
Oh i see
okimii stop using bot commands
i was checking what boolean None returns and i was correct False
so its like comparing False with a False string doesnt matter
why not
i fixed that
I want that my bot adds a role to a member when he joins
does the gateway send an event on a guild join probably does i just dont know where in docs
async def on_member_join(member):
role = discord.utils.get(member.guild.roles, id=948925738856374292)
await member.add_roles(role)````Here's my code
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions And thats the error i get
The error says everything
But the member intents are true
Your bot doesnโt have the permissions to add roles
And he got admin on the server
Who is the bot adding the role to?
The member who joined
Which is?
My 2 acc
Are they also admin?
No they are joining
No, an other role
Does that also have admin perms?
Nope
Hmm thatโs odd
Send role positions
Maybe the role that u are trying to give is higher then bot role
But the bot has admin with his role
๐
whats wrong with the code?
I'm slightly concerned
kek
to use google?
Guys, i get this error when i try to use an image i stored locally:
https://paste.pythondiscord.com/kuwevutoco
This is the variable of the image:
LOGO = discord.File("img\AquariusMC_Logo.png", filename="AquariusMC_Logo.png")
how i use it in the embed
ticketchiusolog.set_footer(icon_url="attachment://AquariusMC_Logo.png", text="AquariusMC ๐")
And when i send the embed
await TICKET_CHANNEL_LOG.send(embed=ticketchiusolog, file=LOGO)
slash command check is probably what you're looking for
Indeed
i have my code here, but the on_raw_reaction_add funktion doesnt work (ig because its in a funktion)
but if i do it outside the war funktion, the variables i get from the war function arent defined anymore
how do i solve this?
https://paste.pythondiscord.com/jifowifojo
you can use wait_for
just use @commands.has_permissions(manage_guild=True) for smaller and easier management
float 
manage_server=True?
that doesnt work
oh fuq i gotta go fix this now
learned that the hard way when a random user started creating channels because it just passed through @quaint epoch
def wait_for(reaction)
?
await bot.wait_for(event: str, timeout)
bot.wait_for("reacion_add")
bad spelling my bad
thank you! <3
there is a wait_for snippet on the discord.py documentation
wait_for
use "raw_reaction_add"
!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**...
@bleak flower
def check(reaction, user):
return user == message.author and str(reaction.emoji) == '๐'
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You\'ve run out of time!')
return
else:
await ctx.send('(ending message here when they react)')
it works like py try: await bot.wait_for('raw_reaction_add', timeout=60, check=check_here) except asyncio.exceptions.TimeoutError: # This code runs when the the timeout ends else: '''This code runs when the the event is run and the check returns true before the timeout is over'''
where is the if statement that can work with the else
or am i dumb because i got rid of mine but it still works
you can add an else after a try/except if the except isn't run
def check(reaction, user):
return user == message.author and str(reaction.emoji) == '๐'
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You\'ve run out of time!')
return
else:
await ctx.send('(ending message here when they react)')
like this?
it's asyncio.exceptions.TimeoutError and use "raw_reaction_add" instead of "reaction_add"
raw didnt work for m
everyones sus
!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.
read the docs on how to use this payload
!d asyncio.TimeoutError
exception asyncio.TimeoutError```
The operation has exceeded the given deadline.
Important
This exception is different from the builtin [`TimeoutError`](https://docs.python.org/3/library/exceptions.html#TimeoutError "TimeoutError") exception.
asyncio.TimeoutError works fine
i dont think itsasyncio.exceptions.TimeoutError
mine is inside of a command
it indeed isn't
and btw, check should be like py def check(payload: discord.RawReactionActionEvent): '''the payload in this case if you used raw_reaction_add would be RawReactionActionEvent'''
this is getting overcomplicated
tl;dr, read the docs and use raw_reaction_add
because raw_reaction_add always get reactions, reaction_add only sometimes
!pypi discord
A mirror package for discord.py. Please install that instead.
in the docs, they literally use client.wait_for('reaction_add')
eh
lol
!pypi discord-py
dont use the mirror lol

it gets auto installed when download dpy
ive been accidentally using both
iirc it doesnt i think theres a difference hence one of them being a mirror
๐ฅด
i just pulled out like 5 grams of ear wax out and now i can hear colors
do you think a discord bot takes away much upload speed?



