#discord-bots
1 messages · Page 473 of 1
shouldnt be too hard
ohk
I need an idea for a bot to make ;-;
wdym documentation? do i just need this piece of code?
or do i need this too?
idk which documentation
Well I never used that, but I told to see the documentation folder
can i use both client.event and bot.command()
jesus christ my eyes
why not just do @bot.event? 🤔
Unless you define and client and bot together, not you cannot
And you shouldn't
Use bot
@heavy folio what's even tagscript tho?
If you are already using it
ok
typescript?
First, you can, but you shouldn't.
Second, why do you even want to do that?
idk
No
Typescript is completely different thing lol
idk
very good response
ikr
mhm
If you're just bored, you can go outside.
I mean if you do
client = bot = commands.Bot(...)
It would work, but you should never do this
I would go outside but it's cold, wet and dark.
nah im not
It can cause naming issues and confusion
Or
bot = commands.Bot(..)
client = commands.Bot(..)
is there a way i can check if a song is being played in my bot ?
ok
Are you playing this music from YouTube?
yeah
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
it causes the naming issues still right due to using 2 clients?
That wouldn't work tho
Just don't. Use 1
You can only run one constructor
Why are we still discussing the use of bot and client at the same time?

wait thats a rule ?!
bot.run()
client.run() won't work
Yeh
you can do client.loop.create_task(bot.start())
what if i dont want to do it from youtube, then how can i check if it is being played in ?
like as in general
Rule 5 is that we cannot provide support for something that can break laws/ToS, and streaming music from YouTube is against their ToS.
Oh, hmm, that's possible too lol
Background task
But why would you do it lol
Why would you do any of this. just use one
alright, but if it was like in general then how would u go about seeing if the music is being played or not ?
But its not
Wait, do you own the channel called MenuDocs?
No, but I am on the team.
Oh
Wassup
wdym "why"
e.g. like carl bot
u get to make custom commands and if u do the delete block ({delete}) it'll delete command invocation etc
can you make a bot that keep logs of what commands have been used?
Yes
Dang, ok
Sure can
start() is a coro
i have to use bot.commands right i cant do it only with client.event?
You'd want on_command_completion iirc
hmm i cant find anything online tho
That'd give you every command run. I use it for my command stats command
I assume your wanting something like that?
Love me a good statistics
Do you also track who said the command? Like 'Gnomeslayer said add item 15 times'
No
sigh
This bot only has 1 user, so no need
Do you save the commands externally so if the bot goes offline you maintain the statS?
Correct, all stored in mongo
Noice
The base of the command is also open source as well cos tut
Although I should probably justify string widths lol
no more like:
("!hello") command as been used in ("channel") at (00:00) by (user#0000)
like that but it saves the logs in a txt file
why txt file? why not csv file? 🤔
!d discord.on_command_completion
discord.on_command_completion(ctx)```
An event that is called when a command has completed its invocation.
This event is called only if the command succeeded, i.e. all checks have passed and the user input it correctly.
Still want that, just save it differently
neat imma create my own commands stats :3
whats the difference?
Easier to import into excel
ok thanks
i'd use a json
ok
if it's between txt and csv, go with csv.
Does anyone have a course suggestion where I can learn the discord module?
Check pins
whats this error
i cant it gives me a error when i download it
why are you running your webserver on port 20000
that makes 0 sense, and i told you that earlier
its not working with any other port
what is "not working"
Does anyone know how people do those menus with the reactions that changes page?
🤔
thanks
np
can someone help me with this?
vc.play(self.source, after= what should be here?)
Pagination
a function
a non-async function
hmmm ok
What's that?
You can use discord-ext-menus for pagination
@hasty iron
its because the ipc server cant connect
ipc client*
but why
Is there any way to track if someone reacts to a message
because its not running?
Hello. I'm doing research to make a BOT that reads embeds. I'm tryna code it in Python (obv) where should I learn ?
is the ipc server running
backend is working so yes
on the same machine
Reading embeds are really simple
yes
You need to get the message object that has an embed
Yes but where do I learn that
For example
Yes...
Does anyone have a up-to-date course suggestion where I can learn the discord module?
i am getting a error in my bot
ok what is it
Embeds = message.embeds # message is the message object and embeds returns a list of embeds that are in the message itself
print(str(Embeds[0].title)) # if the embed has an title, it will print the content of the title and Embeds[0] is the first embed in the list of embeds that was returned from attribute .embeds```
Ofc this is just an example
You can make it much better
why is it binding to ipv6
wdym
::1 is the localhost for IPv6
am i supposed to connect to ipv4
so what should i do
no clue tbh
Are you trying to read embeds sent?
i have no idea why its trying to bind to ::1
Maybe it's an issue with replit?
Because they are doing this on replit
Why does my commands stop working when I added an event?
You didn't call process_commands and an normal on_message event will block your commands as it overrides the default on_message event
replit cant interfere with arguments passed into functions
is it possible to make buttons with discord py
yes
You need to call process_commands in the event or use
@bot.listen()
https://ext-creators.github.io/docs/ipc/latest/modules/server/#discord.ext.ipc.server.Server it says here that it defaults to localhost
No not that
I am talking about the ipv6 issue
::1 thing
you have to explicitly pass it in lol
I see
either pass in a socket.socket with the AF_INET6 family into loop.create_server or something else
replit cant mess with that
Oh I see
!d discord.ext.commands.Bot.listen
listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").
Example...
Read this for more info about external event listeners
why ::1?
it says TypeError: <lambda>() takes 0 positional arguments but 1 was given
how do i fix this? im doing after = lambda: event_loop.create_task(self.a())
help??
@discord.ui.button(label="Invite Me", url="https://discord.com/api/oauth2/authorize?client_id=862915751174078465&permissions=8556379383&scope=bot%20applications.commands")
async def link(self, button: discord.ui.Button, interaction: discord.Interaction):
pass
error```py
Traceback (most recent call last):
File "main.py", line 22, in <module>
from help import HelpCommand
File "/home/runner/help.py", line 25, in <module>
class about(discord.ui.View):
File "/home/runner/help.py", line 58, in about
@discord.ui.button(label="Invite Me", url="https://discord.com/api/oauth2/authorize?client_id=862915751174078465&permissions=8556379383&scope=bot applications.commands")
TypeError: button() got an unexpected keyword argument 'url'
send all of your code
@stiff nexus does the button have url kwarg?
what
does the button have a url kwarg
YES
maybe read the docs on 3rd party libs
no i am not using repl anymore
@red nest Make sure not to sure your token
oh sorry
You should regen your token ^ @red nest
you will have to buy a domain first
and run the web server on a service like heroku
yeah ill do it now
i am using ipc
thats why i need to use it with my bot
cant you run the server separately?, no?
is there any way i can add my website
no i cant
else ipc is not working
ok can someone help me now it says member not found in the unban command
because it doesnt found the member "mee6” in the ban list?
Should discord.member be guild.member?
i banned him before
no
@lament mesa
can someone please help me and tell me why this is ahhpening?
after = lambda: event_loop.create_task(self.next_sound())
it says TypeError: <lambda>() takes 0 positional arguments but 1 was given
how do i write it so that bot will join my vc when i type (prefix)join?
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
any simple way to make space in commands without using message.startswith?
Someone is calling this function with an argument.
Can you show more code?
its realy just that
https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient.play
If this is what you're using, it explains that your function should accept one argument.
oh
you shouldn’t use loop.create_task
in the after
you should use asyncio.run_coroutine_threadsafe
hello?
@client.command()
async def banner(ctx, *, bannermember : discord.Member=None):
if bannermember == None:
bannermember = ctx.author
userBannerUrl = user.banner_url
embed = discord.Embed(title=f"{ctx.author}'s banner", color=0x030203)
embed.set_image(url=user.banner.url)
await ctx.send(embed=embed)
what am i doing wrong
🙏
If that's true, that's some crucial information missing from the docs
that's a weird place to put it
any help?
Fix error plz help
bannermember not user 😛
if it's part of the contract for this function, it should be in the docs for this function
Ok ill try
you have define the member as bannermember not as user
Someone tell mee how to add a domain to my flask server
need help
still not working lol
@client.command()
async def banner(ctx, *, bannermember : discord.Member=None):
if bannermember == None:
bannermember = ctx.author
userBannerUrl = bannermember.banner.url
embed = discord.Embed(title=f"{ctx.author}'s banner", color=0x030203)
embed.set_image(url=user.banner.url)
await ctx.send(embed=embed)
heres the code
thats the error
...
you need 2.0 installed
py 2.7?
discordpy 2.0
hii
How to create a category using a bot?
!d discord.Guild.create_category
await create_category(name, *, overwrites=None, reason=None, position=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Same as [`create_text_channel()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`CategoryChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.CategoryChannel "discord.CategoryChannel") instead.
Note
The `category` parameter is not supported in this function since categories cannot have categories.
thanks
yes
🤔
Do you have a frontend?
You can have your web-app on heroku and give it a domain
help pls when i used @bot.event after @bot.command it's not working
y?
they already have once since they're on replit
i think they want a custom domain
oh
will there be updates in discord.py for now on?
nope
str.rjust(width[, fillchar])```
Return the string right justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`.
!e py print("hello") print("s") print("s".rjust(5))
@bitter depot :white_check_mark: Your eval job has completed with return code 0.
001 | hello
002 | s
003 | s
ooh
@drifting arrow ^^
How do I use the guild's icon as the author?
url=guild.icon.url
That worked, but not i wanted. so I came up with another solution.
How do I prevent everyone from viewing a category?
@client.command(aliases=['tm'])
async def tempmute(ctx, member: discord.Member, duration: int, time: str, *, reason="None"):
guild: discord.Guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="Muted")
if not mutedRole:
mutedRole = await guild.create_role(name="Muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
embed = discord.Embed(title="Muted!", description=f"{member.mention} has been tempmuted ", colour=discord.Colour.light_gray())
embed.add_field(name="Reason:", value=reason, inline=False)
embed.add_field(name="Time left for the mute:", value=f"{time}", inline=False)
await ctx.send(embed=embed)
await member.add_roles(mutedRole)
if "s" == time:
await asyncio.sleep(duration)
elif "m" == time:
duration_min = duration * 60
await asyncio.sleep(duration_min)
elif "h" == time:
duration_hour = duration * 3600
await asyncio.sleep(duration_hour)
elif "d" == time:
duration_day = duration * 86400
await asyncio.sleep(duration_day)
await member.remove_roles(mutedRole, reason=None)```
the code and the error coming when i m running the command
me?
yes
Having units line up with your hundreds smh. At the very least zfill please
why it gives error when i try i:
alright thanks
and vaule?
!e py print(100) print(1) print("1".zfill(3)) @drifting arrow
@bitter depot :white_check_mark: Your eval job has completed with return code 0.
001 | 100
002 | 1
003 | 001
that also seems wrong...
no i have used rightly
whatchu type in discord
other error py interaction = await client.wait_for("select_option", check = lambda i: i.component[0].vaule == "A")
!e py print(100) print(1) print(f"{1:>3}")and this if you don't want the leading 0s @drifting arrow
@bitter depot :white_check_mark: Your eval job has completed with return code 0.
001 | 100
002 | 1
003 | 1
++tempmute {user} 1d {reason}
1d is a string
send full code?
you see
@client.command()
async def selectmenu(ctx):
await ctx.send("Pick one of the buttons.", componets = [Select(placeholder="Select One Of The Values", options=[SelectOption(label="A", value="A"), SelectOption(label="B", vaule="B")])])
interaction = await client.wait_for("select_option",
check = lambda i: i.component[0].vaule == "A")
await intercation.respond(content = f"You have selected `{interaction.componet[0]. label}`")```
well uhh this is confusing.. ```py
mystatuses += (f"{str(self.stats[x]['Uses']).zfill(3)} \n")
you indented wrong
me?
@client.command()
async def selectmenu(ctx):
await ctx.send("Pick one of the buttons.", componets = [Select(placeholder="Select One Of The Values", options=[SelectOption(label="A", value="A"), SelectOption(label="B", vaule="B")])])
interaction = await client.wait_for("select_option",
check = lambda i: i.component[0].value == "A")
await interaction.respond(content = f"You have selected `{interaction.componet[0]. label}`")```
try that?
So split it into a variablepy uses = self.stats[x]['Uses'] mystatuses += f"{uses:>3}\n"
Imo even justpy mystatuses += f"{self.stats[x]['users']:>3}\n"is an improvement
so what should it be?
No centred under uses
Now I feel violated coz the number is on the left and not centered or right ;-;
maybe 1
Show your code
how do you want to convert 1d to an int
@commands.command()
@commands.is_owner()
async def printstats(self, ctx):
embed = discord.Embed()
mystatname = ''
mystatuses = ''
embed.add_field(name="Statistics", value="The statistics on how many times you've used each command.", inline="False")
for x in self.stats:
print(self.stats[x])
mystatname += (f"{self.stats[x]['Name']} \n")
mystatuses += f"{self.stats[x]['users']:>3}\n"
embed.add_field(name="Commands", value=mystatname, inline="True")
embed.add_field(name="Uses", value=mystatuses, inline="True")
# filename and extension have to match (ex. "thisname.jpg" has to be "attachment://thisname.jpg")
await ctx.send(embed=embed)
!d discord.Guild.default_role
default_role```
Gets the @everyone role that all members have by default.
means?
🤨 ...
thanks
❓ ❔
what does that means ?
You did ['users'] not ['uses'] there btw
so you can't make blabla to a number
so should i use 3600
you can do that
that's exactly the opposite of the tag
wsp with the error
ctx.guild.default_role
thanks you
you'res welcome
for value in self.stats.values():
mystatname += f"{value['Name']}\n"
mystatuses += f"{value['uses']:>3}\n"```try something like this maybe
@client.event
async def on_ready():
print("The bot is ready to be used!")
DiscordComponents(client)```
anyone
@slate swanty that worked

No changes @bitter depot
event dont need ()
for which?
????
his last error lol
i am confused
What's the output when you print the variable
the function definiton always has brackets
how i fix this?
No he did @client.event()
well it looked liked it
I dunno, that code just seems right
I don't know if he should put that discordcomponents stuff in on_ready
probably not
Where can I see a list of all channel permissions?
so do i do @client.event()??
permissions_in(channel)```
An alias for [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").
Basically equivalent to:
```py
channel.permissions_for(self)
sheesh
Print it not send it
@rare saddle
thanks you so much
np
@bitter depot
tbh i think it's just the way discord embs shit
coz it even removes spaces
Apparently in embs as well. coz when I uglify it even more..
Maybe do inline codeblock instead?
oh
See how that looks
so 1 `?
And would still format
yea
What started off as a thing I thought would take an hr tops ended up with me spending like 3hrs on ;-;
Trust me that's normal in coding
BUT OH BOY!
No Category:
help Shows this message
Type $help command for more info on a command.
You can also type $help category for more info on a category.
I got a whole new statistics thing
!charinfo
\u200b : ZERO WIDTH SPACE -
THATS A THING?
str.rjust(width[, fillchar])```
Return the string right justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`.
f"{value['uses']:>3}\n"```copy-paste this (it has the zws in it)
yep lol
defaultdict
mutable-default-args
there's many attr for str
whats the error..
the hell
8.7. Function definitions
A function definition defines a user-defined function object (see section The standard type hierarchy):
no ()
@opaque trail
event
where
bot.event
@bot.event without ()
@client.event
async def on_ready():
print("The bot is ready to be used!")
DiscordComponents(client)```
but bot instead of client..?
yes
You have client so use client ._.
depends on what you are using tbh
yes
So how i fix it
im using bot so bot for me
just use that code
i did
and it should be fine
i have it
ok and does it work
nope
hm
Also @bitter depot after this, I get to go back and add these new features to my fun facts code!
HECK YEAH!
this is confusing
Welcome to code \o/
And remember to name stuff properly or else you'll wake up tomorrow being like 'dafuq is this shit do?' and spend like 10 minutes figuring it out
and never! EVER! leave your code on an error.
fix that error THEN go to bed.
Or leave a note.
You're why I have trust issues
I release releases on pypi that include errors 😈 😈 😈 😈
print('Hello, world!')
!e print("Hello World")
@drifting arrow :white_check_mark: Your eval job has completed with return code 0.
Hello World
\o/
!e print(eval("2 + 2"))
@opaque trail :white_check_mark: Your eval job has completed with return code 0.
4
@bot.event
async def on_raw_reaction_add(payload):
message_id = rct_msg.id
if message_id == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '👍':
member_id = member.id
member_id = str(member_id)
registered = reg_user.append(member_id)
reaction = await bot.wait_for('reaction_add', check = registered, timeout = None)
message = await bot.wait_for('message', check = lambda message: str(message.author.id) in reg_user and message.channel.id == my_channel.id, timeout = None)
if message.content.lower() == 'registration complete':
await my_channel.send(embed = discord.Embed(title = 'Successful!', description = 'All users registered!', color = discord.Color.green()))
members = ctx.guild.members
user_id = message.author.id
for member in members:
member_id = member.id
if str(user_id) in str(member_id):
reg_users = my_channel.overwrites_for(ctx.guild.default_role)
reg_users.send_messages = True
print('true')
else:
else_user = my_channel.overwrites_for(ctx.guild.default_role)
else_user.send_messages = False
else_user = my_channel.overwrites_for(member_id)```
I'm trying to create a feature where if someone reacts to a reaction ``:thumbsup:``, they get appended to a list which gives them access to a particular channel, but I'm having trouble executing this with the error telling me ``my_channel.overwrites_for()`` can't be a string, only a member/role, so what should I do?
else_user = my_channel.overwrites_for(member)
shouldn't it be reg_users = my_channel.overwrites_for(member)
it didnt work
no functionality difference
that's still not useful
you want the error
of course
there is none
no error
the code just doesn't function as intended
what does it do
as in, when I use my ALT account to view the same channel, it should not be able to send messages in the channel because it didn't register by reacting to the emote
but it can send messages
discord config issue?
im not sure to be honest
then what do I do?
a config problem
there is no feedback from console
check your channel configurations in the server
or maybe my code is messed up
dunno
what are channel configurations
like how I set up the server?
the settings right
yes
bro this error
send the code
import discord
from discord.ext import commands
import random
import os
import aiohttp
from discord_components import *
client = commands.AutoShardedBot
(commands.when_mentioned_or("+"))
@client.event
async def on_ready():
print("The bot is ready to be used!")
DiscordComponents(client)
@client.command()
async def selectmenu(ctx):
await ctx.send("Pick one of the buttons.", components = [Select(placeholder="Select One Of The Values", options=[SelectOption(label="A", value="A"), SelectOption(label="B", value="B")])])
interaction = await client.wait_for("select_option", check = lambda i: i.component[0].value == "A")
await interaction.respond(content = f"You have selected `{interaction.component[0].label}`")
interactionb = await client.wait_for("select_option", check = lambda i: i.component[1].value == "B")
await interactionb.respond(content = f"You have selected `{interactionb.component[1].label}`")
TOKEN = os.environ ['TOKEN']
client.run(TOKEN)```
That's all the code u have?
Yeah
How can I fix a command just not working? Like I type in the command in Discord but nothing happens
code?
No error, nothing. I just type it and it don’t work
Yeah 1 sec
@client.command(aliases=["SERVERINFO", "Serverinfo", "Serverinformation", "SERVERINFORMATION", "serverinformation"])
async def serverinfo(ctx):
embed = Embed(title="Server information",
colour=ctx.guild.owner.colour,
timestamp=datetime.utcnow())
embed.set_thumbnail(url=ctx.guild.icon_url)
fields = [("ID", ctx.guild.id, True),
("Owner", ctx.guild.owner, True),
("Region", ctx.guild.region, True),
("Created at", ctx.guild.created_at.strftime("%m/%d/%Y %H:%M:%S"), True),
("Members", len(ctx.guild.members), True),
("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True),
("Bots", len(list(filter(lambda m: m.bot, ctx.guild.members))), True),
("Text channels", len(ctx.guild.text_channels), True),
("Voice channels", len(ctx.guild.voice_channels), True),
("Categories", len(ctx.guild.categories), True),
("Roles", len(ctx.guild.roles), True),
("\u200b", "\u200b", True)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
await ctx.send(embed=embed)
do u have an error handler?
@crude crater if u want to do like that, I prefer u use this
@bot.event
async def on_raw_reaction_add(payload):
message_id = rct_msg.id
if message_id == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '👍':
member_id = member.id
member_id = str(member_id)
registered = reg_user.append(member_id)
reaction = await bot.wait_for('reaction_add', check = registered, timeout = None)
message = await bot.wait_for('message', check = lambda message: str(message.author.id) in reg_user and message.channel.id == my_channel.id, timeout = None)
if message.content.lower() == 'registration complete':
await my_channel.send(embed = discord.Embed(title = 'Successful!', description = 'All users registered!', color = discord.Color.green()))
members = ctx.guild.members
user_id = message.author.id
for member in members:
member_id = member.id
if str(user_id) in str(member_id):
reg_users = my_channel.overwrites_for(ctx.guild.default_role)
reg_users.send_messages = True
print('true')
else:
else_user = my_channel.overwrites_for(ctx.guild.default_role)
else_user.send_messages = False
else_user = my_channel.overwrites_for(member_id)
!d discord.Embed.from_dict
classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") to a [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") provided it is in the format that Discord expects it to be in.
You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
!paste
What’s the error?
No
like this
@crude crater
!code
oh thx
Copy and paste the back ticks with the “py”
@bot.event
async def on_raw_reaction_add(payload):
message_id = rct_msg.id
if message_id == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '👍':
member_id = member.id
member_id = str(member_id)
registered = reg_user.append(member_id)
reaction = await bot.wait_for('reaction_add', check = registered, timeout = None)
message = await bot.wait_for('message', check = lambda message: str(message.author.id) in reg_user and message.channel.id == my_channel.id, timeout = None)
if message.content.lower() == 'registration complete':
await my_channel.send(embed = discord.Embed(title = 'Successful!', description = 'All users registered!', color = discord.Color.green()))
members = ctx.guild.members
user_id = message.author.id
for member in members:
member_id = member.id
if str(user_id) in str(member_id):
reg_users = my_channel.overwrites_for(ctx.guild.default_role)
reg_users.send_messages = True
print('true')
else:
else_user = my_channel.overwrites_for(ctx.guild.default_role)
else_user.send_messages = False
else_user = my_channel.overwrites_for(member_id)
It’s right next to the 1 on your keyboard to the left
ik
Word
can someone help?
discord.py is kinda outdated, idk if buttons work on that, try py-cord
hey again
i want to make a log for lets say if someone joins the general call, in a text channel it tags the user and say that he joined
my current code is
@commands.Cog.listener()
async def on_voice_state_update(self, ctx, before, after):
logschannel = 886341890734186536
if before.channel is None and after.channel is not None:
if after.channel.id == 886331304944214077:
await ctx.logschannel.send("Alarm!")
And...? Whats the last part, I.e your question / error so we can help
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
for some reason all the perms are the same
My dashboard working now
when accessing the value of the key from old_perms they're the same as the ones when i'm looping in after.overwrites (i printed them out, they were the same)
@slate swan can I ask u a question?
what
I mean if want to send a msg that I typed in the dashboard but it's not a event nor a cmd so how can I make my bot send the msg
idk, never made a dashboard
I mean is there anything in the dpy lib that can do this
discord.py isnt for web
idk any
@hasty iron I don't mean that
as i said never made a dashboard
..
i know what you’re asking
I mean I want to send a msg from my dashboard but what shall I use in dpy that can help me send the msg cause it is not a cmd nor a event so is there anything else
make something yourself, dpy offers nothing to do what you’re thinking
I mean any tasks or something like that?
tasks?
actually wont you have to write js to make something like user input and make it show
@valid perch I am just trying to send a msg but how cause if I even set a msg in dashboard and sent it from there then how will it get triggered in the bot
Cause it's not a cmd nor event
And that's the place I am getting confused
how would the bot know where to send the message
Ipc can be used in your dashboard and it'll talk to your bot. Essentially it calls a function on your bot, then in the function you can get channels, send messages, etc. See the docs for the link I sent.
Ok
heyo guys if i use prefixes.json and upload it to github will it still work??
cause i use heroku
help
me
Probably better to use an external database
is there a command decorator that allows a specific user do bypass perms? like how there's one for roles, is there one for users?
whai bro
i have the same question
i use heroku for now
futuredate = datetime.datetime.utcnow() + timedelta(seconds=timewait)
TypeError: function missing required argument 'year' (pos 1)```
why wouldn't it?
can we both work together to test and find out
and if i ignore the file will it work?
ok i will try
in .gitignore
My question is everytime i push to heorku master it will overwrite it r8?
cuz my local file is not updated
well can we work together????????????
It'll pull the changes you made into your current files
ignored
how lol

emoji management , read my about me
ohk
how many server??
futuredate = datetime.datetime.utcnow() + timedelta(seconds=timewait)
TypeError: function missing required argument 'year' (pos 1)```
Full error?
that is full error
how can i fix this it says delete is not defined:
await delete(guild.text_channels, reason=None)
No documentation found for the requested symbol.
!d discord.TextChannel.delete
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the channel.
You must have [`manage_channels`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
someone help ??a
Can I have 2 same events in one cog? if yes, how do I do it?
but why
I am checking 2 different thing on_member_update and I want to code it organized
I can stick with 1 function but I rather 2
mhm
!d discord.ext.commands.Cog.listener
classmethod listener(name=None)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
not said
well I'll just stick with 1 event itll be good
well it doesn't have any pros to have it in 2 events....
anyone got the link to the github page where there was a list of bad words??
Google probably does
I believe that timedelta() requires a year argument.
nah
it doesn't require anything
!d datetime.timedelta
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
all are optional
change_presence() missing 1 required positional argument: 'self', does anyone know how to fix it?
async def on_ready(self):
self.client_id = (await self.application_info()).id
activity = discord.Game(name= "-help", type= 3)
await commands.Bot.change_presence(status=discord.Status.idle, activity=activity)
uhhh
you need to make an instance of bot o.O
ugh
you need a commands.Bot instance
and not copy paste it in your code 
ok
you have bot?
or client
or whatever your commands.Bot is, just use it instead of commands.Bot
ok
AttributeError: module 'discord.ext.commands.bot' has no attribute 'change_presence'
I have bot = commands.Bot
Why is this idle thing not working? await client.change_presence(status=discord.Status.idle)
gamesession is not defined
are you sure its not working?
it takes some seconds to change it to idle
Can anyone help me
dont ask to ask
how to make a bot to send message in one channel
use get_channel to get the channel by using its id and then use .send to send a message to that channel
!d discord.ext.commands.Bot.get_channel
get_channel(id)```
Returns a channel with the given ID.
I use heroku for hosting for now.. I tried adding *.json in gitignore file so that it ignores my local changes in json file . But it doesn't work, any solution to this?
Have you committed the gitignore before seeing if local changes appear?
How to install lavalink?
Yes i commited the .gitignore file before i test if it actually works
@client.command()
async def eat(ctx, member:discord.Member=None):
wc = Image.open('cats-eating-bananas2.jpg')
draw = ImageDraw.Draw(wc)
font = ImageFont.truetype("font.otf", 40)
text = (f"{ctx.member.name}")
draw.text((394,340), text, (255,255,255), font=font)
wc.save('eatmeme.jpg')
await ctx.send(file = discord.File('eatmeme.jpg'))
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'member'
It's ctx.user
how do i create an invite for a guild
what i did didnt work but i suck at using docs so i'm not suprised
Oops
bro what
!microsoft
Microsoft Visual C++ Build Tools
When you install a library through pip on Windows, sometimes you may encounter this error:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
This means the library you're installing has code written in other languages and needs additional tools to install. To install these tools, follow the following steps: (Requires 6GB+ disk space)
1. Open https://visualstudio.microsoft.com/visual-cpp-build-tools/.
2. Click Download Build Tools >. A file named vs_BuildTools or vs_BuildTools.exe should start downloading. If no downloads start after a few seconds, click click here to retry.
3. Run the downloaded file. Click Continue to proceed.
4. Choose C++ build tools and press Install. You may need a reboot after the installation.
5. Try installing the library via pip again.
thanks
!source
l = await guild.create_invite(reason="New Guild",max_age=0, max_uses=0)
``` wont work
show the whole code
@bot.event
async def on_guild_join(guild):
db[f"{guild.id} welc"] = f"NEW GUILD {guild.id}"
db[f"{guild.id} msg"] = f"`SET NEW MESSAGE`"
db[f"{guild.id} footer"] = f"SET NEW FOOTER"
l = await guild.create_invite(reason="New Guild",max_age=0, max_uses=0)
embed = discord.Embed(description=f"New Guild Joined\nGuild Name: `{guild.name}`\nMember Count: `{guild.member_count}`\nGuild Owner: `{guild.owner}`",color=color)
channel = bot.get_channel(887497183203581982)
await channel.send(embed=embed,
components=[
Button(
style=ButtonStyle.URL,
label="Guild Invite",
url=l
)
]
)
It's against ToS
huh ?
Creating invite without a server's consent upon joinng or later is considered as a privacy breach
that is the dumbest shit ive ever heard im sorry so ima have to ask if i can invite someone to a server like what ?/
is the bot private or public?
lol
"dumbest shit ive ever heard"
How does it not work? Does it give an error?
Bigbren
manz literally said its privacy breach
l = await guild.create_invite(reason="New Guild",max_age=0, max_uses=0)
AttributeError: 'Guild' object has no attribute 'create_invite'
You need to create an invite on a channel object
thought so
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Nvm
Hmm, I mean, it could be kinda mean if your bot is invited to a private server and it sends you an invite
Lmao It's clear
it could also used for other things
nothing...
what a smart look up
👏
Indeed
I mean, you spelled inviting wrong, but I don't think its going to be written exactly in the TOs
Welp, I guess when people invite the bot they do consent for it to be creating invites since it's a permission
And you are helping him
Well I just realized this
Although would not suggest doing it. People don't like that sort of thing.
He's gonna end up getting reported if his bot ever be used in public/private servers
Like this
Yup.
any way to access someones profile banner while using dpy before 2.0
?
what
ur chats werent loading
oh ok
werent loading? what
how is that even confusing, ur chat wasnt loading it was showing up as blank
wifi problem
..
oh
yea
Lmao i thought it was like loading videos
well it showed up on my screen
Hello guys I wanna get into coding python discord bots but because discord.py is dead what would be the best alternative ?
It's not dead, yet. But you can start to use a fork of discord.py
@hasty iron @reef shell got it thank u guys
much love
all forks are shit lol
I was looking into pycord is it the same syntax with discord.py?
Not sure
Honestly some forks I would suggest over others, since they don't change it too much
Use disnake
You've got the best implementation of slashes so far and the lib is really up-to-date unlike other libs in some parts
The syntax is identical to the one of dpy 2.0
I’m gonna give it a try thnx for the recommendation
Yw
hey, does anybody know how to search youtube instead of using urls with ffmpeg and youtube_dl? here's my code: ```py
@commands.command()
async def play(self,ctx,url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
vc.play(source)
await ctx.send(f"Now Playing {url}")```
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
oh right youtube hates music bots
lol
Sending logs each 15 seconds shouldn't be API abusing right? I have events for whenever a Role is changed/added/deleted, when a member/user updates their profile and all the other events which are appended to a list making a list of embeds and with a task.loop I'm having it send using the embeds kwarg via a webhook in the logs channel
Shouldn't be too spammy right? 
yeah
i thought of saying to use a semaphore or a lock then at second thought, that wouldn’t work
Depends on the ratelimits
Webhooks have a ratelimit that I think is about 30 messages per 10 minutes per channel
Something close to that
actually, a lock would work
Huh
I think I've sent more than 30 messages in 10 minutes
same
Idk what that is 😔
Ah 30 messages/minute sounds good
Since I can send 10 embeds per message
That would mean 300 embeds per minute 😱
DMs to a member who has DMs closed falls under HTTP Exceptions right?py elif isinstance(error, discord.HTTPException): await ctx.send(embed=discord.Embed(title="Unknown HTTP Exception", description=f"Please report this in the support server.\n`{error.text}`", colour=self.bot.error_colour,))
I don't think you can put a number in the name when you are defining a command
so instead of _8ball, try _ball
it should accept it with a _8ball, now 8ball itself will probs produce a error
yes 8ball itself will produce a error but maybe _8ball might as well
it wont
but then again, we don't know the error
lmao
spammy?
definitely
is it giving you an errors in the terminal when you run the bot?
@bot.command(aliases=["mc", "members"])
async def membercount(ctx):
guild = ctx.guild
members = await ctx.guild.fetch_members().flatten()
member_by_status = Counter(str(m.status) for m in guild.members)
online = (f'Online: {member_by_status["online"]}\n'
f'Idle: {member_by_status["idle"]}\n'
f'Do Not Disturb: {member_by_status["dnd"]}')
offline = (f'Offline: {member_by_status["offline"]}')
count = sum(1 for people in members if people.bot)
real = f"{members}-{count}"
embed = discord.Embed(
description=
f"```Total Members: {ctx.guild.member_count}\nBots: {count}\nHumans: {eval(real)}\n{online}\n{offline}```",
color=discord.Colour.from_rgb(114, 137, 218))
await ctx.send(embed=embed)
``` explaintion on why this wont owrk
Command raised an exception: AttributeError: 'Guild' object has no attribute 'get_members'
my bad
did you mean len(guild.members) ?
Command raised an exception: TypeError: 'list' object is not callable
what
wait, why would you need that member var.
Why my slash command dont work?
you don't need to use .flatten() if you use guild.members
is that a question?
bro it just created more errors
yes
i cant run the bot
so what error is it giving you in the terminal
why are you showing the token lol
Xd its classic bot all peoples can create it
I can regenerate it thats not problem slash is the problem
try str(len(guild.members)) @slate swan
okay
define "dont work"
my initial assumption is that you're expecting it to appear immediately but since it's a global slash command it'll take ~1hr
didn't work
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client").
New in version 1.5...
did you try guild = guild.members ?
wait nm you did
hold on
try client.get_guild(GUILD ID) @slate swan
I think /commands are only for professional bots like arcane and stuff and you leaked your token that's meant to be a secret that's your bots password
they regenerated it
they realized lol
Ok good lmao
Ikr
For debug/testing, append guilds_ids = [] so @slash.slash(name = name, guild_ids = []) and add the guild id of your test server.
I thought that was a discord feature only lmao
also try adding enabling intents in your bot and add this your main script
client = Bot(command_prefix="prefix", intents=intents)
intents = discord.Intents.default()
intents.members = True
Are there any python libraries that support / commands?
by April next year all bots need to convert to slash commands (unless it's in less than 100 servers and doesn't intend to grow). Some bots might get exceptions (like mod bots)
Much appreciated
!pypi dislash.py
how can i make it so i dont have to mention a role i can just type the role name but it still works
Why did you define intents after client?
Typehint your argument to discord.Role and it will take a mention, name, or even ID.
!d discord.Role
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild")...
Typehint means something:something.
For example:
async def rolename(ctx, role:discord.Role):
print(role.name)
oh i have tha
Then you already don't need to mention the role.
@bot.command()
async def role(ctx, member:discord.Member,role:discord.Role):
await bot.fetch_ctx.guild.roles()
await member.add_roles(role)
embed = discord.Embed(description=f"{check} gave {role.name} to {member}",color=color)
await ctx.send(embed=embed)
its not gonna make me mention?
You don't need to, no.
What's fetch_ctx?
Remove the await bot.fetch_ctx.guild.roles() since it will just raise an error.
yea ik i fixed it
do you think i'll get terminated for having this watchinf thing in my status, even tho i'm using a google extension
No, Discord doesn't care about that afaik.
because like i know you could do the activities with a selfbot so i jsut wanna make sure i don't get terminated
Anyone use discord-components? How do I make my buttons have like red and green color?
does anyone know how to make an arguement be abl to include spaces?
(reply if you respond)
@visual rivet
async def command(self, ctx, *, arg):
!command all of this will be in arg
arg would be all of this will be in arg
oh ok thanks
?
does anyone know how to do this
oh thanks
mhm
weren't you just in discord.py official server
what
yall are all life savers in this server
i didnt know how to put in in words but thats what i was finna ask
explain
lmao
@client.command(aliases=["SERVERINFO", "Serverinfo", "Serverinformation", "SERVERINFORMATION", "serverinformation"])
async def serverinfo(ctx):
embed = Embed(title="Server information",
colour=ctx.guild.owner.colour,
timestamp=datetime.utcnow())
embed.set_thumbnail(url=ctx.guild.icon_url)
fields = [("ID", ctx.guild.id, True),
("Owner", ctx.guild.owner, True),
("Region", ctx.guild.region, True),
("Created at", ctx.guild.created_at.strftime("%m/%d/%Y %H:%M:%S"), True),
("Members", len(ctx.guild.members), True),
("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True),
("Bots", len(list(filter(lambda m: m.bot, ctx.guild.members))), True),
("Text channels", len(ctx.guild.text_channels), True),
("Voice channels", len(ctx.guild.voice_channels), True),
("Categories", len(ctx.guild.categories), True),
("Roles", len(ctx.guild.roles), True),
("\u200b", "\u200b", True)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
await ctx.send(embed=embed)
how do i make it orange
No error, doesn't work, nothing happens when I use the command
one sec ima show what i mean
like that
I don't know
For as powerful as Discord is, you’d think it would be easy to change your text color, but that’s not really the case. Can you change your text color in Discord?
Check out the full guide at TechJunkie.com!
https://www.techjunkie.com/discord-change-text-color/
Music:
Pold - Summer Vibe
https://soundcloud.com/pold-music/summer-vibe
hello
im making a discord bot for my school server
and i need to be able to display lists in anmbed
im using replit
please ping me if you can help me
put list name in embed data
no
or will this put it horizontally
horizontal
pretty sure that works
uhh
print("\n".join(listname))
that will print everything in the list on separate lines
What's a cool project I could make using a discord bot? 🤔
Make a game of connect-4 with working AI 
Lol
hey can anyone teach me how to make a kill command in discord.py?
What do you mean by kill command?
like
if I do kill @testguy the bot will say @rugged tinsel killed @testguy
or something like that
so like $kill @taggedperson
@Gnomeslayer killed @taggedperson?
yes
Just get the mentions.
Create a new command called "kill" or whatever you want.
Then grab the mention of the author. and the person they mentioned
you can use arguments
@bot.command()
async def kill(ctx, user : discord.Member):
await ctx.send(f"{ctx.author.mention} killed {user.mention}")
😮
tysm bro!
dont give him the answers! I get yelled at whenever I do it. stop it. @sick talon
why? is it againest the rules?
idk probably. something something spoonfeeding etc.
oh
oh ok sorry
didn't knew about it
tbh i have nothing against it. Sometimes people need examples to learn
It's just all the whining and nagging. gets at ya.
Anyway
@rugged tinsel @sick talon this is what I wrote
@commands.command(help='[Pew Pew.]')
@commands.is_owner()
async def kill(self,ctx, member : discord.Member):
if ctx.author.mention == member.mention:
await ctx.send(f'{ctx.author.mention} has just killed himself.. for the 16th time..')
else:
await ctx.send(f'{ctx.author.mention} has killed {member.mention}. <Sigh> _Not again._')
took some creative liberties
Could even create a list of random remarks the bot will append to the end of the 'kill'
nice!
help, how can i make when i can't find a user, send a message?
noice
Like if the member isn't in the server?
When a user didn't mention a user ?
yes, but also when they simply put a letter or word
use a try/except?
not necessarily
I was testing, but it goes without it
wdym ?
This is the error you'll get if you cant ban someone discord.ext.commands.errors.MemberNotFound: Member "@Oliveoil#9305#212" not found. so either yeet a try/except in there or search the actual discord for its members
?
I do not talk a lot of english, sorry





