#discord-bots
1 messages Β· Page 492 of 1
would it do 2 power 10 power 2 times 8 ?
yeah
waiting for danny to change his mind and finally adds slash commands π 
i dont think he would , i saw a work that had it
all the http endpoints are already implemented in 2.0 for slash commands
so all you have to do is add the classes and stuff
okay how would I get the correct size of 8mb
What were you trying to send?
Depending on what you were trying to send you could prob compress it or do some other thing to get it under 8mb
a file that can be maxxed out at that size, but I set the size of the file
if you set the size of the file try setting it lower then what you had earlier
Since what you had was a bit over 8mb
How aboit tring
await ctx.send(files=discord.files('your file dir')
I hope it works. if not i'm so sorry.
I'd guess for some reason it adds a few megabits
or how's using google cloud?
nah, i just need to set the file to a little smaller
so basically I'm asking what is the size of 8mb lol
its either 1024 or 1000 kb but discord has never anwered which they use
umm ok
well if they didn't answer it won't be hard to check it for yourself
Theres only two choices so, just do trial and error see which works ig
Hmm.. I guess andy's right.
well
i found something
somehow this file is bigger than what discord allows??
(this server does not have 50mb per user)
that's because mod,reason,timeand warn_id contain lists
what do i do with the embed if its giving me this error?
@client.event
async def on_message(message):
if str(message.channel.type) == "private":
modmail_channel = discord.utils.get(client.get_all_channels(), name="modmail")
embed = discord.Embed(
color=0xffffff,
timestamp=datetime.utcnow()
)
embed.add_field(name="Modmail", value=message.content)
embed.set_author(name=str(message.author))
embed.set_thumbnail(url=str(message.author.avatar_url))
embed.set_footer(text=f"ID: {message.author.id}")
await modmail_channel.send(embed=embed)
elif str(message.channel) == "modmail" and message.content.startswith("<"):
member_object = message.mentions[0]
index = message.content.index(" ")
string = message.content
mod_message = string[index:]
embed = discord.Embed(
color=0xffffff,
timestamp=datetime.utcnow()
)
embed.add_field(name="Modmail", value=mod_message)
embed.set_author(name=message.author.display_name + " " + "(" + str(message.author) + ")", icon_url=message.author.avatar_url)
embed.set_thumbnail(url=str(message.guild.icon_url))
await member_object.send(embed=embed)
you could do
warns = users[f'{user.id}']['warns']
moderator = users[f'{user.id}']['mod'][0]
warn_reason = users[f'{user.id}']['reason'][0]
warn_time = users[f'{user.id}']['time'][0]
warn_id = users[f'{user.id}']['warn_id'][0]
what host platform do you recommend?
oh yeah sorry you don't need the [0] on the warns because its already just an int warns = users[f'{user.id}']['warns']
yes, leave the warns as they are before, i overlooked that
no, the same as before
this should work
hi guys
i've set up a bot that on command goes to a specific voice channel (specified by channel id) and plays an audio file
how would i make it go to a different voice channel if
the command was used in a specific text channel (defined by id)
ah, you want to do that
@bot.command()
@commands.has_permissions(administrator=True)
async def warnings(ctx, user:nextcord.Member):
with open('warns.json', 'r') as f:
users = json.load(f)
warns = users[f'{user.id}']['warns']
moderator = users[f'{user.id}']['mod']
warn_reason = users[f'{user.id}']['reason']
warn_time = users[f'{user.id}']['time']
warn_id = users[f'{user.id}']['warn_id']
await ctx.send(f"Warning count: {warns} Given by:{', '.join(moderator)} For:{', '.join(warn_reason)}At:{', '.join(warn_time)} IDs:{', '.join(warn_id)}")
this should work
!d str.join and if your wondering what's up with the ''.joins
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3.10/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3.10/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
can anyone help me?
ah,
await ctx.send(f"Warning count: {warns} Given by:{', '.join(str(mod) for mod in moderator)} For:{', '.join(warn_reason)}At:{', '.join(warn_time)} IDs:{', '.join(str(wrn_id) for wrn_id in warn_id)}")
i forgot you need to convert all values inside the list to strs
np, sorry if the help i gave was subpar
well yes you shouldnβt
hi guys
i've set up a bot that on command goes to a specific voice channel (specified by channel id) and plays an audio file
how would i make it go to a different voice channel if
the command was used in a specific text channel (defined by id)?
I got my modmail system to finally work but now none of my commands are working and thereβs no error
Hey @outer violet!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
this is my current code https://paste.pythondiscord.com/umusodosay.rust
at the end of your on_message add client.process_commands(message) if client is discord.ext.commands.Bot, also rename client to bot if its discord.ext.commands.Bo
how to see all permission a role has
!d discord.Role.permissions if you have the role object you can use this
property permissions: discord.permissions.Permissions```
Returns the roleβs permissions.
thanks!
is it possible to dm someone a webhook in discord.py?
I don't think it's possible to use webhooks in DMs
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Your every move!"))
shiii
why dont you make a bot?
but intents have a problem
Ah, well, i fyou mean a bot just sending an embed, then yes of course it can do tahat
its easier in my opinion
its in a bot lol, i need said bot to dm someone an embed
how
OOOOOOOOOOOOH
Sending a message to a user has the same parameters as to a DM
It is showing intent error
intents = discord.Intents.all()
File "/root/chad/bot.py", line 273, in <module>
bot.run(token)
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 723, in run
return future.result()
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 601, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.```
You can send it using the member.send method
intents = discord.Intents.all()
embed = DiscordEmbed(title='test', description=f'test', color='0x548dff')
i did tht
i need em to dm that
enable intents in your bot
Intents need to be enabled in the developer portal
@urban sphinx it shows
yeah i got the member intent
enable the intents
its verified
i cant enable all, how can i only enable serve intent
250+ its a long story
help, how i make a bot dm someone this
if its in 100+ you need to get it verified
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.Client "discord.Client").
New in version 1.5...
But for now i rlly need help
you need to send discord your id
They have said it's verifiex
IT got verified
oh
Today
@urban sphinx help.
discord.Intents.guilds
perhaps this?
or no
hm
no not that
thats only server intents
discord.Intents(guilds=True)
So what all intents do i need?
discord.Intents.all() usually works
Well, depends on which ones you are using
but it doesnt cuz i dont have prescence
or discord.Intents.default()
who
Command raised an exception: AttributeError: 'DiscordEmbed' object has no attribute 'to_dict'
got that error when i tried
await ctx.author.send(embed = DiscordEmbed(title='test', description=f'test', color='0x548dff'))
Dude i need help asap
What is DiscordEmbed? It's not something I recognize
idk but its beeen working for just sending the embeds in a server
embed = discord.Embed()
embed.title = "bla bla bla"
embed.description = "etc etc"
await ctx.send(embed=embed)
You can pass those two as parameters
aye it worked!!
but how do i set the color in this version, cuz the 0x548dff got an error
You can use the discord.Color object
you can try doing
!d discord.Colour
discord.Colour
class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)").
There is an alias for this called Color...
where i put that doe
embed.color = discord.Colour
emb = discord.Embed(title = "Giveaway!", description = f"{prize}", color = discord.Colour.blue())
emb.add_field(name = "Ends at:", value = f"{answers[1]}")
emb.set_footer(icon_url=ctx.author.avatar_url,text=ctx.author.name)
bruh = await channel.send(embed = emb)
stole this from my giveaways command
await ctx.author.send(embed = DiscordEmbed(title='test', description=f'test', discord.Colour.red()))
no no
like that?
Needs to be the color kwarg
await ctx.author.send(embed = DiscordEmbed(title='test', description=f'test', color = discord.Colour.red()))
do you want to send it
to a dm?
yes
oh okay
how do i make it send the timestamp with it
Its literally the same thing. embed objects work the same way being sent anywhere.
mhm
but how i set it up for the dm
the exact same way
Build the embed the same way you built it when you were sending it in a guild
yeah im using webhooks for the server but im tryna dm the embed to somenoe
Why are you using webhooks for sending one thing, and the bot for dms? Why not just use the bot for both?
?
discord.User.send(embed=embed)
idk i coded it dumbly
he wants to send it to the author
await ctx.author.send(embed = discord.Embed(title='test', description=f'test', color = discord.Color.green())) guys this works just fine
all i gotta know is how to add the timestamp
to that
timestamp()
just add a comma? then timestamp()?
what do you think a context author is?
i think yeah
The exact same way with your webhooks
embed = discord.Embed(...)
embed.set_timestamp()
await ctx.author.send(embed=embed)
the person that sent the command
It's a discord.Member object I think
its both User and Member
it depends where the current context is.
If not in a guild its a User object
discord.abc.User
its just in a priv server with like 5 people
AttributeError: 'Embed' object has no attribute 'set_timestamp'
can someone send me a list of discord scam links
dm_embed.set_timestamp()
await ctx.author.send(embed = dm_embed)```
that didnt work
What code are you using for your webhook?
I see you using this DiscordEmbed object that I don't recognize
timestamp is attr.
you dont use a method to set it
embed = DiscordEmbed(title='a', description=f'a', color='0x548dff')
embed.set_author(name="a")
embed.set_timestamp()
webhook.add_embed(embed)
webhook.execute()```
^
and it works just fine
from discord_webhook import DiscordWebhook, DiscordEmbed
oh, its a third party lib.
Rip, yeah I would re-write that to use discord.py as well
Idk then
π¦
Just read the docs for that lib then.
i cba to re write it just for a timestamp
for the dm one im using discord.py
But looking at the docs for discord_webhook, you should be able to just do
from datetime import datetime
embed.timestamp = datetime.now()
What are webhooks and why do I want to use them?
?
never used a webhook before lol
Which does this, it looks like
def set_timestamp(self, timestamp=None):
"""
set timestamp of embed content
:param timestamp: (optional) timestamp of embed content
"""
if timestamp is None:
timestamp = time.time()
self.timestamp = str(datetime.datetime.utcfromtimestamp(timestamp))
idk wtf im looking at its fine i can go w/out the timestamp.... to much work for just a number
wot
never not have timestamps
I believe you might be able to just do this
oh yeah, that worked but it said it was 12:48, but its actually 7:48...
Dude you're confusing yourself. We gave you all the resources you need to do this
aye bruh chill
you said you're using discord.Embed() and not the DiscordEmbed() from that 3rd party lib
ye
So just
Probrably timezone differences
.
??
i literally said it worked??
Try this then
from datetime import datetime
embed.timestamp = datetime.utcnow()
aye worked, solid stuff boys thank you everyone for helping
All me. I take all credit. You're welcome
makes sense
What? wasn't like you were sitting here not contributing.
Geesh. learn to not contribute so you can take credit.
@glad leaf Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!
no, its not.
Then why is it coming up blue ;-;
You could easily check things you know, if you have a linter or if whatever you're writing in has syntax highlighting.
is it a reserved word in sql? π€
Because you're in a string.
thats interesting then.
for y in ["β
", "β"]:
await confirm_embed.add_reaction(str(y))
def reaction_check(rctn, usr):
return usr.id == ctx.author.id and str(rctn) == 'β
' or str(rctn) == 'β'
rctn, usr = await self.client.wait_for("reaction_add", check=reaction_check)
can someone check if I'm doing this right?
did you test it?
This keeps happening before I react
can you send full code pls.
Wondering if you actually put any logic in for that or if you're just sending regardless.
Hey @trim barn!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
I feel like the error might be in the logic here
return usr.id == ctx.author.id and str(rctn) == 'β
' or str(rctn) == 'β'
Might want to add some ()
return usr.id == ctx.author.id and (str(rctn) == 'β
' or str(rctn) == 'β')
why this keep spamming
That was the error
You probably have more than one instance of your bot running in the background
try going into taskbar and closing them
How does that even happen? lol
Thank you. tfw when I forget basic algebra
well I use Pycharm so i wouldn't know
maybe using atom and hit run one too many times
^
Nothing else to do.. Time to i guess update my bot to stop using csv and json files lol
Yeah. im gonna need to rewrite this entire thing ;-;
Use a db I suggest Postgres
I'm using aiosqlite
pls tell me some good discord bot host :)
i was using heroku π cuz i used it before also
Heroku sucks for bots
I'll fetch you the list
that's why i used and also i don't know any other good host
but now the free dyno of heroku are over :(
so i am finding new host
Need to run your bot 24/7? Get a cheap VPS.
https://www.scaleway.com/ EU https://www.linode.com/ US/EU/Asia
https://www.digitalocean.com/ US https://www.vultr.com/ US
https://www.ovh.co.uk/ EU/Canada https://www.hetzner.com/ Germany
https://www.time4vps.eu/ Lithuania.
Self-hosting: Free hosting: Kinda free:
Any computer. No. Not even heroku. GCP, AWS have one year free micros.
Three distinct solutions to address your cloud infrastructure needs, your dedicated server solutions & hardware hosting
Our mission is to accelerate innovation by making cloud computing simple, affordable, and accessible to all.
Helping millions of developers easily build, test, manage, and scale applications of any size β faster than ever before.
is it free π
All are paid, there's no good free option except self hosting
but i can never use a paid option π
Then self-host
??
Run it on your own PC
but i cannot keep my pc 24/7 on :/
Plot twist: he codes on mobile. /j
-_-
Do you want to host just a Discord bot?
how to make as your bot joins a server it sends an text in the first channel it sees
Well you could reach up to hosting services. Some of them are free. I recommend https://somehost.xyz
Free and paid hosting
In my own opinion, if your bot isn't very large. And I'm speaking about very large numbers, like 10,000+ servers. A VPS would be just a waste of money.
Especially when it's written in Python, as Python uses so much less resources than Node.js and a few other languages.
how to make as your bot joins a server it sends an text in the first channel it sees
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
you can host on repl but you'll need to google how to set it up.
it would not work well if you intend to grow your bot but it's fine for small scale
replit?
yh
use the event , and you can get a list of text channels using guild.text_channels
.this one
could this work?
@client.event
async def on_guild_join(guild):
try:
joinchannel = guild.system_channel
# The system channel is where Discordβs join messages are sent
await joinchannel.send('Thanks for inviting me to your server!')
catch:
# if no system channel is found send to the first channel in guild
await guild.text_channels[0].send(<message>)```
yep , but this works only if the server has a system welcome channel
yeah it will
replace catch with except tho
guys, id like to learn more about self hosting
um i am starting making music bot using python kindly help
they use VPS
virtual private server
they use different modules too
music bots are kind of against tos now , especially one using ytdl
!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)
oof
brings error down here
replace <message> with a string you want to send
hey how to give this role to my bot this role is managed by integration. This role cannot be given to users
Upon inviting a bot it gets a role managed by integration
Replit isn't a hosting site
This role cannot be given to users
Meaning it's automatically given to boosters, bots
yeah
Unless you have an alternative to offer it is
how can i make it send an embed instead of words?
send(Test)```
Like my bot is not getting that role
it isn't
I want my bot to get that role
wait wrong
π
Wdym? It already has it when it joins the server
huh?
its not
yes sure
it is..
when joined a server my bot is not getting that role
Meaning?
Show your bots role
like wait
!d discord.Guild.create_text_channel @lyric moat here
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a βsecretβ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
Kk
There is dyno bot when the bot joins a server it will automatically creates a with its name and assign itself
That's discord's thing
I want this to do for my bot
thats not happening
Show your bot's role?
the bot is in many servers
can i add an embed?
show the roles
to py .send(Test)?
it works only if you invite the bot with some permissions
https://discordapi.com/permissions.html
A small calculator that generates Discord OAuth invite links
for var name is for like tittle and etc?
@boreal ravine
no?
the one where you defined what your embed variable is
so how i made the embed embed?
@boreal ravine
yes the one where you defined discord.Embed(title=...., desc=...., url=....., color=.....) as
if not 'https://' in message.content.lower: what is wrong with this?
Its an int not a string
You should read the error lol
.lower should be .lower() as str.lower is a function.
oh awesome thanks!
Then it was added with 0 permissions.
When the bot is added with 0 permissions, it doesn't get a role, even if it got a role with administrator permissions later on. It will have to be added to the server with the administrator permissions.
!d discord.ActivityType
class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
this embed so confusing
No, you just don't understand what's an int.
You know what str and int is?
I suggest you learn Python's basics before touching discord.py.
nvm nvm
i found out
why it gives an error?
File "main.py", line 41
except:
^
SyntaxError: invalid syntax```
Use a third party lib
Maybe because you didn't do the except yet?
I already said "colors in embeds are integers" how is that confusing..
i did
but same thing
except:
# if no system channel is found send to the first channel in guild
await guild.text_channels[0].send(test)```
It's because your using a useless parentheses at color
it's not a good idea to copy paste code
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if itβs within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
AttributeError: 'TextChannel' object has no attribute 'add_reaction
code:
await channel.add_reaction(':white_check_mark:')
any help?
Maybe because you didn't install the module yet..?
might be, or maybe you type it wrong?
read the documentary
i remember when i install a lib, the package name is different when i import it
from discord.ext import commands
from discordTogether import DiscordTogether
client = commands.Bot(command_prefix="~")
togetherControl = DiscordTogether(client)
@client.command()
async def startYT(ctx):
link = await togetherControl.create_link(ctx.author.voice.channel.id, 'youtube')
await ctx.send(f"Click the blue link!\n{link}")
client.run("BOT_TOKEN_HERE")
Did you try that?
btw any help for this?
why are oyu trying to add a reaction to a channel
Did u install it though?
You're using replit. Try going to the package menu
And search discord-together
oh yeah lol, how do i react to the message?
do you have the message object?
to which you want to add the reaction
what is that !?!
is it a message you've sent or a message someone else has sent
AttributeError: 'TextChannel' object has no attribute 'message'
@slate swan try it pls
i add message
code: await channel.message.add_reaction(':white_check_mark:')
see? :)
you need a specific message, a channel does not have only 1 message @sweet merlin
!d discord.TextChannel.message
No documentation found for the requested symbol.
reply uses poetry internally. Poetry installs into its own venv. Trying to add stuff via pip doesn't always work on repl
!d discord.TextChannel
class discord.TextChannel```
Represents a Discord guild text channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channelβs hash.
str(x) Returns the channelβs name.
np
Its best not to use replit. it isnt made for discord bots. use an actual editor/IDE like VSCode or pycharm
yes
how? i tried to make a voting listener
that is better
way
the replit is not good
send the rest of the code
dm?
here itself
@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
return
else:
channel = self.bot.get_channel(884996199629860864)
await channel.message.add_reaction('β
')
await channel.message.add_reaction('β')```
IDE's can run code too. If you wanna host it 24/7, use something like heroku(again, heroku isnt made for discord bots, but its free) if you want something better, use a VPS. it costs like 2$ a month
try message.add_reaction(), remove channel.
eh? how do i get that cheap price
ok
heroku isnt made for discord bots
i remember seeing it somewhere. dont remember tho
yeah, thats what i said
hold up
hmmm
didnt that gonna react to all message in all channel?
ratelimiting
yeah its gonna react to all channel
no, i dont think it will
it did
it will react to that specific message
well...
at least it should
what is a good and cheap vps?
what message do you want it to react to?
spesific channel
he's using an on_message events
like a poll channel
presumably he wants every message in that channel reacted to
yeah
oh
use an if statement, if message.channel == channel: then send it
you would have to check if the message's channel is equal to the one you want to react to
wait imma read the discordpy documentary agian, i forgot what is the message for
is channel going to be channel id or my variable channel?
"documentary"
pretty sure there's a message.channel_id you can use if i recall correctly
the variable which you defined
alright
or more likely just message.channel.id
aight its working! thanks guys!!!
Docs?
yeah sorry for my bad spelling/grammar
np it was just a joke
so im trying to make it so whenever a user dms the bot, it responds back with "this message has been sent to staff" or like in embed form or something but idk where i would put it in my code which is this currently https://hastebin.com/awexefahoh.properties
can someone help?
if isinstance(ctx.channel, discord.channel.DMChannel):
do something
Share code manπ¬ π¬
look at the down messsage
where would i put that
i think change the if str(message.channel.type) == "private": to that
line 9
<:emoji:>
ooo thx
wait
Do :emoji: then add a backslash like \:emoji:
Then copy it into the embed
ohk
not custom emoji:
\:emoji: copy it and paste
example:
\β
custom emoji:
u get the code first \:emoji: copy it
then use it example: !ducky_hunt
Normal emoji's you can just do :thumbsup:
some emoji cant do that like β β
on replit*
ooooh
giving me this error
What do u mean
If its a browser emoji it'll change to that
here
\β
the x thing
is this right
are you using message or ctx? im confused
message
change the ctx to message
cuz this
What
yeah i dont see the full of his code
He gave that, you'll change it
my bad
If it's an event change it to the correct params
okay it works now
how do i get it to only send it once and not every time someone sends a message?
what you mean?
Is there a way you can make your own vc games or whatever they are called
voice recognitize or something like that? ( i dont know how to spell it)
No no a game like chess
Chess already exists so something else like that
u want cooldown? or only once?
if only once you can make like true false thing
because if you bot goes down/off/logged off it will be reset
only once. itll get annoying if it sends every time
Discord VC party games that's what they are called
I never heard of it
uhh can you give example please?
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
Please
try make a variable and make it false when it runned:
test = True
async def on_message():
test = False
if test == false:
return
else:
do something```
it will loks like that
oh
Eee can someone tell me how to have custom Discord VC party games?
i dont know what u mean, like vc party games with bot?
Ofc
Check it on google
Yk it consists of yt together sessions poker night fishington.io and even chess
oh u mean the bot will live stream?
1 min
ok
It has pre saved ones but I want to know if custom ones are possible
@sweet merlin
?
is there a way to interact with a bot via dms?
i send the bot a specific command, and it does stuff in dms rather than a server?
if isinstance(message.channel, discord.channel.DMChannel):
eh
DMchannel
is it only run youtube?
No there are many games you see
or how would it look?
But I want custom ones
sorry, i dont know how to make it
Is it possible to make them tho?
That's the main question
its possible
guys pleeeeeeeeeeeeeeeease
where it sends a dm? whats the aim here
Um how?
!d discord.Member.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
im trying to interact with my bot inside dms rather than a server
you can do that anyway
how tho
you send a command to the bots dmβsβ¦
@bot.event()
async def on_message():
if 'test' in ctx.content.lower():
if isinstance(message.channel, discord.channel.DMChannel):
do something
else:
return```
i think it should work
so its an event , not command?
thats not a command.
i think u can with commands
commands work in dmsβ¦
listener too :D
yes, but commands are optimised and there are countless reasons why to use commands > events
or
@bot.command()
async def hello(ctx):
if isinstance(ctx.channel, discord.channel.DMChannel):
do something
ctx.message.content
to get the content, you'd do ctx.message.content
do this @vagrant galleon i think it will work
!d discord.channel.DMChannel
class discord.DMChannel```
Represents a Discord direct message channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channelβs hash.
str(x) Returns a string representation of the channel
yes it worked! tysm ill get back to you if i need any other help
yeah it work
np
why u using ctx and message?
can u post a nitro emoji code for confetti
to get the id you'd do \:name:
well i can't help with that
ohk
i don't have nitro either
its ok
how do i authenticate someone to use a command , i want it to be just their command so preferebly by id @slate swan @sweet merlin
u mean getting message id?
no.. i dont want anyone to use a command for example !test
i want just one person based on their id to use this command
or ill give them a special role, but preferebly by discord id
but im the owner of the bot
oh
i want other people to use their own command privately
hmm try using
if ctx.author.id == the id:
do something
sure
permissions = discord.Permissions()
permissions.update(kick_members = False)
await role.edit(reason = None, colour = discord.Colour.blue(), permissions=permissions```
more: https://discordpy.readthedocs.io/en/latest/api.html#permissions
i think it should work
what does it do
i want a command that closes a channel for other users itks this server also has a similar command
Update the channel's overwrites and make the guild's default role's send_messages set to False.
!d discord.Guild.default_role
property default_role: discord.role.Role```
Gets the @everyone role that all members have by default.
!d discord.PermissionOverwrite
class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.
Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.
The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.
x == y Checks if two overwrites are equal.
x != y Checks if two overwrites are not equal.
iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
ok ty
@client.command()
async def test(ctx):
await ctx.channel.set_permissions(ctx.guild.default_role, see_messages=False)```
i think it will work
umm what is default role here and see messages ? becuz im also gonna check permissions
its changging the @everyone roles
that i dont want
i just want to restrict ppl with no permissions to be able to type anythin
view_messages
ok
How to check if the user is already in a VC?
why does the dying command not work but the slash command does? it was working like yesterday https://hst.sh/dirafofepo.py
because you're defining dying twice
ah ok
You can do commands.MemberConverter=None btw converter isn't needed
commands.MemberConverter=None
o cool
umm
ok yea ty this worked
@bot.command()
async def test(ctx):
voice_state = ctx.member.voice
if voice_state is None:
# Exiting if the user is not in a voice channel
return await ctx.send('you are not in vc')
discord.guild.has_role('Bot') is this correct
what is this place?
this is a channel for discussing discord bots, hence the name
I wanna create one do I use python?
read the channel topic to know more
I know absolutely 0% about coding
then learn python /coding first
I have to pay cash? :(
^
nah
then how
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
no
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
there are many free good sources online
!commands
unless you wanna buy some online courses
any1
hi im new
welcome
i dont know anything about python or coding
!resource
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
thanks
i just want to learn
you want to get a role object?
yes
ctx.guild.role,send_messages=False role is the var
this was on stack but i dont want default_role
so.....
idk what you are looking for .. this might help you find roles
https://discordpy.readthedocs.io/en/latest/api.html?highlight=utils#discord.utils.get
ok
@bot.command()
@commands.has_permissions(manage_channels=True)
async def pause_all(ctx):
role = discord.guild.has_role("new role")
await ctx.guild.channel.set_permissions(ctx.guild.role,send_messages=False)
await ctx.channel.send("All channels have been paused pls wait...")```i just wanna puse a channel for the general role but not #everyone
@reef shell
role = discord.utils.get(ctx.guild.roles, name = "general")
k
then do whatever you want to do with the role
Hey, if I want to use Discord Timestamp for userinfo commands to show member.created at and joined_at, how do I convert the times into the ones needed for the timestamp?
doesnt work
@bot.command()
@commands.has_permissions(manage_channels=True)
async def pause_all(ctx):
role = discord.utils.get(ctx.guild.roles, name="new role")
await ctx.guild.channel.set_permissions(ctx.guild.role,send_messages=False)
await ctx.channel.send("All channels have been paused pls wait...")```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
member.created_at.timestamp() gives you the unix timestamp (float), you need to convert it to integer and then do the timestamp formatting
it should be (role, send_messages= False) in line 5/6
same error
do i?
you need a specific channel to set permissions
ok so for all do i need guild.channel or guild is enough
you can get a channel obj. using the same method you used to get a role obj
got it, thanks mate
like channel = discord.utils.get(ctx.guild.text_channels, name = "channel-name")
then do
channel.set_perm........
yeah but i dont wanna just pause 1 channel
then you need to use loop
i wanna pause the channel where themessage has been sent
for channel in ctx.guild.text_channels
Umm
like this
async def say(ctx,arg):
await ctx.send(arg)```
what lib
you want to pause/lock all the text channels or only the context channel?
pause it
i asked something else
Use ctx.channel.edit and remove the send perms from everyone role
i dont wanna remove frome everyone
like in this
except the default role i want it to be specific to one role
like i said , you need to use loop for this
Yea
oh
this then
ok so this will close all text channels?
ok let me spoonfeed you
no
role = discord.utils.get(ctx.guild.roles, name="new role")
await ctx.channel.set_permissions(role,send_messages=True)```
y wont this work
for channel in ctx.guild.text_channels:
channel.set_permission(role, send_messages= False)```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissionsthe error
this will do for all ri8?
but i hv given
1 sec
i hv done a send message after pausing which is showing error
```` await ctx.channel.send("Channel has been unpaused")```
however the bot doesnt hv the role
also @reef shell if i do for channel is guild.channels: it shows AttributeError: module 'discord.guild' has no attribute 'channels'
i hv to use Guild?
!custom-check
Custom Command Checks in discord.py
Often you may find the need to use checks that don't exist by default in discord.py. Fortunately, discord.py provides discord.ext.commands.check which allows you to create you own checks like this:
from discord.ext.commands import check, Context
def in_any_channel(*channels):
async def predicate(ctx: Context):
return ctx.channel.id in channels
return check(predicate)
This check is to check whether the invoked command is in a given set of channels. The inner function, named predicate here, is used to perform the actual check on the command, and check logic should go in this function. It must be an async function, and always provides a single commands.Context argument which you can use to create check logic. This check function should return a boolean value indicating whether the check passed (return True) or failed (return False).
The check can now be used like any other commands check as a decorator of a command, such as this:
@bot.command(name="ping")
@in_any_channel(728343273562701984)
async def ping(ctx: Context):
...
This would lock the ping command to only be used in the channel 728343273562701984. If this check function fails it will raise a CheckFailure exception, which can be handled in your error handler.
@potent jetty ^^^
Well u can do for guild then
It's just so that u understand how to do so
Nope
U will have to compare member.guild then
if member.guild.id == guild-id
Or member.guild == bot.get_guild()
Mhm
But that won't send the message if the guild id is that one
Ah
Well then remove that return statement
And add yr logic instead
Yea
hm
except discord.MissingPermissions:
await ctx.send("My role is not high enough to give you roles. Ask a moderator/admin to move my role above your highest role in order for me to give you roles.")
```that would work right
no ?
discord.Forbidden
maybe if I made a game using discord π€
hello anyone know why my bot is ofline
code?
because you didn't run the file
maybe you put the wrong token? or you didnt run the file?
its runing
i did
can you show me the code?
No he means show code.
whats the error then
he might be type the token wrong
We can only speculate at this point in time. Without the actual code we won't know.
or something
It could be your bot is online you just set it to offline
Or your bot is set to the wrong code.
Imagine not copying and pasting the token tho :')
u cant do that tho (offline status)
U can
Not in discord.py
It doesn't matter. no code. can only speculate
you can
you can?
yeah
U can
how..?
online, busy, streaming, offline
!d discord.Status.offline
The member is offline.
What?
"member"?
await bot.change_presence(status=discord.Status.offline)
-_-
Do it
discord.Status.busy is going to be busy status?
what the hell
yooo
Β―\_(γ)_/Β―
Told u
so whats the problem?
hm
It would be. but im all outta ideas and I've tried nothing
hm
Buttons ttt
ttt?
Buttons fight (like how dank memer's fight works)
what is ttt
tic tac toe they mean
Tic-tac-toe
Oh.
tictac toe is nice but the problem is you need to make sure that only 2 players can use it can they dont use it on each others turn
easy enough done
that can be one
You could play w/ the bot
well that is not how dpy works.. i tried but i still dont get how to do it
yup that is easy
How it works?
whats the difference between that and commands.MissingPermission?
is discord.Foridden for missing perms
Ty
yes
no that is you are not allowed to do it
missingpermission is you dont have the perms to do it
no that is you are not allowed to do it
This can be because of missing perms too
discord.foribidden means discord doesnt allow you to do it
o
well no..
ohh
yes discord does not let you do it because you are missing perms...
hmm
but missing perms is a dpy thing not a discord thing
Forbidden also gets thrown for missing permissions
^
not always
it happens rarely
can
Most of the time when you try to send a message where you're not allowed to, you get Forbidden, so no it happens quite often..
but its rare
commands.MissingPermissions: Permissions Error
discord.Forbidden: Discord Error
^^
and missing perms is because of the decorator @commands.has_permission()
Not rocket science Β―_(γ)_/Β―
man do you even know what it means lol
or are you guessing
Meaning?
i c
MissingPermissions is when the invoker, not the bot doesn't have the permissions to use the command
And you need to add a decorator or similar for it to work
yea that is what i meant
that is why i told here
no that is you are not allowed to do it
missingpermission is you dont have the perms to do it
discord.Forbidden = Bot not allowed
commands.MissingPermissions = Invoker not allowed
https://discord.com/developers/applications > Bot Description
hi
Bot description
i want to make slash command in cogs
aight thanks
in discord developer portal
how do i do
it depends on the lib you are using
discord.py does not support slash commands
you cant make slash commands in dpy
You need to use a third party library
yea
discord-py-slash-command?
sorry i dont noticed it
can you give me an example code im new with slash
yup
i c
π
By the way it didn't say this before about me's released lol
Finally has a use
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.
alr nice
can i have 2 emojis at once
in the same line of code
can emoji be a list
Well thank you Captain Obvious
Why would they put it when About Me was not even a thing π€¦
Does len(guild.channels) return number of categories + number of channels? Yes right?
!d discord.Guild.channels
property channels: List[GuildChannel]```
A list of channels that belongs to this guild.
only channels i guess
That's weird.. think it's including categories
lol
