#discord-bots
1 messages · Page 594 of 1
heres the code:
@client.event
async def on_member_join(member):
channel = client.get_channel(908722937077588048)
await channel.send(f'Welcome to the server, {member}.')
await channel.send(file=discord.File(r'C:\Users\c6tan\OneDrive\Desktop\UtangoRun\anotherone.mp4'))```
What do you mean?
Error?
Doesnt give an error, just nothing happens
Do you have the members intent enabled?
I did, and it still wouldnt work
Probably not since it worked with a command
Where and how have you enabled the intent?
Just at the top of my code, next to where i set my prefix and token etc
does https://discordpy.readthedocs.io/en/master/api.html#discord.on_thread_remove mean it got archived?
intents = discord.Intents().all()
Enable in the developer panel
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Head over to your bot and enable the members intent switch
Example:
Just enable the server members
yeah i have that on already
Well you would get an error instead of nothing
Maybe you have an error handler that prevents error from logging
yeah i do, just disabling that atm
Alright, i disabled it and i still dont get an error at all
hmm weird
Not getting anything either means it worked or you don't have the intent (which you have)
Damn thats so weird
i have no idea, i have intents, no error handler and im still getting no error msg
Kind of dumb question, but is a new member joining the server?
Yeah i have my alt acc joining
Just wanted to make sure
This is so annoying lol
Oh wait
Oh waitttt
You did client.channel
yeah lmao
It's just channel.send
i added that a few mins ago to test, lemme try now
Not the same code though
Oh ok

Also, its slightly unrelated to what i just asked, but would you know how i can say "welcome" as the title of the video, instead of sending it after the video, since the video takes a little time to send?
Like how we can upload files and send a message with that file, and kinda attach them to eachother, how would i do that with a bot message?
Just do
await ...send(content="your message", file=the_file)
How do I mention the author of the message
ctx.author
I mean like actually @mentions them
ctx.author.mention
ty
np
so i got this osu command where user does s/osu add <username in osu> and bot saves it n stuff...but once i restart iz bek to square one...so can someone help m econfigure sm json files for it please
!d
how do i use this
Click the buttons?
@slate swan yes, but i want to go specific bits, not these
W8 can u tell what you want? Or im missing something?
for changing guild icon with like an image link.
Is even the bot allowed to do it?
wdym
im testing some stuff with what i can do
Well you can change pfp of dis server
server = self.bot.get_guild(serverid)
await server.edit(name="test" )
If you are using cogs, If not remove self
ok, i already know how to change the name of guild with bot but i just want to change the icon
Then try icon="urltoicon"
embeds.append(discord.Embed(color=0xf80707).from_dict(entry))
```y dont this work...the color i mean
try
embeds.append(discord.Embed(color=discord.Colour.red()).from_dict(entry))
does this work?
One of the cons of not using a database
running on replit too
that doesnt change anything
tried mongodb and smdamn errors came up
https://cdn.discordapp.com/attachments/857194930895323147/908402596035854376/unknown.png
and idk JSON well but i know enough that JSON is not database for you to use
show me the code
code where we add the username? or the pymongo thingy?...coz it errors wen i initiate...like wen i define mongoclient itself
show me ur query thing
iz in the poetry lock file...not in code
one sec
Can anybody say my mistake here?
Capitalization matters.
see bro same thing
u didn't even change it
I changed
what did you change
ok
I wrote Command_prefix
don't tell me you already have all that code below and don't manage to get through the definition of Bot
uhm I think your password is kinda leaked and i also think u wrote the password wrong or smth
I can see the P is still a capital letter
all lowercase
https://stackoverflow.com/questions/65489987/configuration-error-when-trying-to-connect-mongodb-database-in-python @cinder horizon
install dnspython3 or smth
i gtg
Hi, im using numpy.random for a giveaway command but how can I do, for example: there are 30 users who joined in a giveaway (by reactions) and I want to return one winner or more winners (who are not the same user) from the reactions using this package by the code below but there is an error: ValueError: 'a' and 'p' must have the same size. How to do to eliminate the 'p' which is the probability because it doesnt work with the probability added or removed by me if there are more than x users who joined the giveaway.
onewinner = np.choice(users, size = 1, replace = False, p = probability) probability = [0.5, 0.2, 0.3, 0.7, 0.6, 0.9, 0.4, 0.1, 1.0, 0.8] users = await new_gaw_msg.reactions[0].users().flatten()
how do i force a field in embed to be on next line instead on being right?
emb.add_field(name = "", value = "", inline = True)
In discord.Member you get someone by pinging them, but can you do it with a user's ID?
like $ping USER_ID instead of $ping @SomeoneRandom
<@userid> @final shard this works
How can i make a error handler for a command not found?
Use ```py
commands.CommandNotFound
Thx
Hey, i have an issue. My bot is in multiple servers, but im trying to set up a welcome message for just one of them... So ive done that, but now whenever someone joins one of the other 20 servers the bot is in, it gives a notification in the server i want to use the message for
the code is:
@client.event
async def on_member_join(member):
if guild == 908449309224206377:
channel = client.get_channel(908722937077588048)
await channel.send(content=f"Welcome to the server, {member.mention}", file=discord.File(r'C:\Users\c6tan\OneDrive\Desktop\UtangoRun\anotherone.mp4'))
else:
return```
obviously the "if guild == (guild id):
doesnt work, but im trying to find a way to do that and i cant figure it out
isnt if guild.id == ...?
I thought so too, but then i get "unresolved reference 'guild'"
what even are you referencing by guild?
Nothing, i mean im trying to figure out how to only post that message if a user joins THAT specific server
Oh that might work hold on
How to build yt new video notifier like in mee6
Are there any guides or smth
if member.guild.id == some_id
That seems to have worked man, thanks haha i cant believe i didnt think about that
Thanks everyone
aye don't worry, np!
for channel in ctx.guild.channels:
await channel.set_permissions(ctx.guild.default_role, overwrite=None)
when disabling overwrite; i was expecting for the channels permissions to return to back how it was. instead it makes it so every channel has the same perm
Have you stored how "it was back"?
Write the definition of a function power to, which receives two parameters (x and y
respectively). The first is a double and the second is an int. The function returns a
double. If the second parameter is negative, the function returns zero. Otherwise
it returns the value of the first parameter raised to the power of the second. Call
the function with the values 23.1 and 7 respectively. At the end print the function’s
result. (Note: Python’s built-in functions are not allowed.)
It just removes the overwrites for everyone role for every channel
I don't think asking for help with homework is acceptable if it homework
oh, well. when doing this:
for channel in ctx.guild.channels:
await channel.set_permissions(ctx.guild.default_role, send_messages=False)
i want it so when im using overwrite in the thing i sent over there it returns the channel to its defaults. (ex: if announcements has the @ everyone roles send_messages off it'll stay like that and not go back to /)
sorry
Hold up, lemme check the docs rq
iiight
ı won't do it again
@last shuttle seems like you are doing everything alright. So if I understood you right - you want to delete overwrites for a role for a channel?
yeah
im trying to make a lockdown command, so when im trying to disable it puts the channel back to its defaults
so if announcements has the everyone role send messages off it'll stay like that
Uh be careful it might unlock some rules channels automatically
@last shuttle and what does that code actually do, I didn't get it
Instead of what it is supposed to do
im using a testing server i can really care less
Ok
for the first half with overwrite being None, it sets the permissions to defaults (obvo)
and this just changes all the channels send_messages perm to false
i wanna make a simple enable/disable lockdown command
Enable is already made I think
Disable would simply be
for channel in ctx.guild.text_channels:
await channel.set_permissions(ctx.guild.default_role, send_messages=None)```
Sorry if I misunderstood but seems like this is the thing you want
And you want this perm to be?
Then you need to store data of what permissions there were before the lockdown
alright so do i maybe put it in an array
or is that gonna issue in like different servers
actually, yeah. wont that issue in multiple servers?
You may add a simple list and put IDs of channels that had it set to false before a lockdown, when unlocking just exclude them using condition
Will need a database or a dictionary
dict
i dont wanna pay for databses n all that
Databases are free
.
I don't mean server ones
postgres is server based right? And it's free as well (afaik)
You could just use sqlite, will sure need some effort to learn SQL a bit but totally worth it
ok
Idk, I just have my db files on my server
I will show an example
would you be able to aid me within it though?
is this hosted on my pc or like through a lib
unlock_ignored = []
@bot.command()
async def lockdown(ctx):
for c in ctx.guild.text_channels:
if c.overwrites[ctx.guild.default_role].send_messages == False:
unlock_ignored.append(c.id)
else:
await c.set_permissions(ctx.guild.default_role, send_messages=False)
@bot.command()
async def unlockdown(ctx):
for c in ctx.guild.text_channels:
if not c.id in unlock_ignored:
await c.set_permissions(ctx.guild.default_role, send_messages=None)
unlock_ignored.clear()```
@last shuttle
is this using sqlite or am i dumb
You can store unlock_ignored in the way you want
oh alright
Nah
but is sqlite or dict better?
It is just a variable
what should i be using instead
Those are multiserver options, if your bot is only for one server, this is ok
im planning it for like.. multiple servers
Too much to code
so can i use sqlite instead?
You will need to learn the basics of SQL
and if so how does sqlite work
It's kinda uh complicated
Library
hmmm
And database is just a file
Hey guys anyone here good with dictionaries 🙏
I barely know it myself sorry
Yeah
@last shuttle I mean I know it but I am not sure I'm doing things in the right way
I created kind of
Module
For easier managing the databases, but the issue is I added no doc since only I am using it
I could give you the code if you want
So I'm trying to make a q system, where members can !q, once the queue reaches 6 players, the data is saved for other purposes and the queue resets.
uhh mayb later but what lib do i use
I was thinking of using a dict with like {userid: [members]}
import sqlite3
ok
Why would they be attached to a user
Like ID of the user who made the queue should be the key?
what should i put like after the import, are there any like neccesary functions to be run
I will better send you a module, so you can see it by yourself
ok
can you put it in a haste/pastebin?
Actually probably like {gameid: [members]}
Alr
so there are 6 players for every game id
Oh
So what exactly do you want to know, how to save the dictionary?
Or how to make it as well
Yeah so I just want to be able to have multiple q's in the same channel
but the player information is stored so after the game is complete, a win/loss can be reported and the players rating is adjusted in the database
I guess I want to know how I would save the player id's and then be able to recall them later for database purposes
@last shuttle https://pastebin.com/cn4VGZQt
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.
It was in built into the bot utils module so some imports might be useless
is this like a module i can use and just call functions in or
You will need to edit it a bit
It is a part of another module but you don't need the full, so I just put it
If you are going to store the data just for a few servers its better to use json or pickle
Databases are uh recommended but not really necessary if your bot is not serving more than 10 guilds
Once my bot got to 90 guilds I had to recode it from a dumb pickle database I created 💀
lmao
oh god
honestly
i should prob just learn sqlite
since i wanna make like a warn system n all that
but ill do it later
How would u put a dictionary aside then extract values from it
i’m starting to go crazy
Aside like, extract values after the program is finished?
Or just generally how to extract values from a dictionary
@bronze pilot
How to save a dictionary in a database you mean?
Oh if you want to save dictionary data I'd go for JSON
I am using VPS
Seems perfect for this
whats that?
Server
is it paid
Yeah
aw man
It's 3$/mo, not very expensive imho
I just want to be able to create a q system that creates a game id, and holds the members of the game in it. After the game is done, the members id’s can be retrieved based off the game id.
Idk if I need a database for that, I don’t think I do.
Yes
But the catch is that there could be infinite number of q’s, since after one q is full, I want another q to start
Then you create separate IDs for each queue and use those are the dictionary key
but the values are still saved for previous q game id’s
Have you tried to make the system by yourself yet?
yes, just with lists though
Could you show the code?
Well I’ve got a simple q system, haven’t stored game id’s or allowed for several q’s yet.
{
"queue1": {
"user1ID": 123123123,
"user2ID": 345345345
},
"queue2": {
"user1ID": 12132524
}
}
But for each "queue1" or "queue2" etc you can create your own key
This is just a suggestion
off the top of my head
That’s exactly what i’m after
perfect 😄
{
"gameID1": [1234, 5678],
"gameID2": [9876, 5432]
}```
Probably better for this case
Can you show the way of putting the data to the list?
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.
You can use json.load() and json.dump() to read from and write to JSON files respectively
tysm
I’ll have to do some reading on working with json files
One thing to note is that JSON represents data a little differently than how Python does with dictionaries, but the json methods for reading and writing convert the values accordingly
But don't go create a database with it like me 😂
AFAIK pickle doesn't generate a readable file like JSON does, no?
I feel that JSON would be better here cause you'll notice fuck-ups in the file
hey uhhh exe can you help me setup sqlite for my funny thing so i dont have to go through pain after i release my bot 
but with pickle, and ofc only if what I said is the case, you'll be implementing print statements for debugging which could be avoided if you use JSON
Unless what pickle writes to the file is exactly what is in the Python dictionary, idk
I say use JSON 😄
try:
games[gameID].append(ctx.author.id) #add to existing key if exists
except KeyError:
games[gameID] = [ctx.author.id] #create new list with a key if not```
Basically how to add a user to a game @full valley
@bronze pilot json is indeed better if you want to read your file by your own eyes without additional features, but it also has several disadvantages, like it can only store int, float, string, and some other basic types, keys can only be str and you can't store python objects
Or you could use python games[gameID] = [ctx.author.id] and implement a gameID that is based off the past gameID
Pickle is bad af in case your bot is split into modules
yeah lol I was annoyed by this but haven't run into any issues yet
But it's better to use a db then
I want game id’s to just count upwards by 1 each time preferably
So you can do this
@client.event
async def on_ready():
db = sqlite3.connect("main.sqlite")
cursor = db.cursor()
cursor.execute = ('''
''')
print("Bot has started succesfully")
what should i add here
( i want my bot to have like.. lockdown channel perms and warns)
You could create a function like generate_id here's the example
def generate_id() -> int:
return int(f'{datetime.now().year}{int(datetime.now().timestamp())}{randint(1000, 9999)}')```
The thing you are going to do will require storing a bit of more data
Bit of a 4am mind blank, what is games[gameid]
The dictionary is games and gameid is the key you are indexing by
Sry I gtg or I won't do any of my homework with this all lmao
Came to ask how to make a yt video notifier
Nah all g, thanks for the help
s
so you can append to dictionaries, I really gotta go relearn them
I just never use them
ty all for the help
np
Do look into dictionaries, you need to understand them better before you use them
They don't have a .append() method
Dictionaries don't allow duplicate keys, so if you just say my_dict["hello] = 2 and "hello" is not a key in the dictionary, it will create a new key:value pair as "hello":2.
If there is a "hello" key, it will overwrite that key's corresponding value with whatever you've put after =, in this case it is 2
Turn it to date time object?
What is a good way to make bot stay online?
Is heroku good?
Get a vps
This all are vps
Kk, ty
Heroku isnt recommended or suitable for discord bots go for a vps as shown above
Raspberry pi does the job, heavy initial investment though
are there any like free alternativse to vps and raspberry pi
self host is the only option
damn
aws gives 1 year free but it requires cc
use google
and i found this too
idk what that is
some hosting site i found
earlier today
Wanna host your discord bot but you can't afford any VPS because of no payment method? This video is for you, cause I'll show you 3 different 100% free discord bot hosting services, and one of them even allows you to easily build your discord bot and take care of the hosting! Make sure you gonna subscribe and turn on the bell notification😉.
0:0...
from this
You won't go far with 128mb of RAM
Seems like a shady service
i am trying to make jackpot but it doesnt work
when i get 3 equal items
its not jackpot
Yes.
for users in ctx.guild.members
would this work
for users in ctx.guild.fetch_members(limit=None):
print(users)
tried this (yes intents are enabled) and it dont work
Hi, how can i add 🇺🇸 as a reaction to message in discord.py
I know how to add normal emoji, but i can't copy this emoji for some reason, it will just paste "us". (emojipedia)
how to send direct message to user from self_bot
wdym by self_bot
Send \:emote: in a Discord cannel and copy the emote that got send after sending it
Then use .add_reaction(emote) on a Message object
Selfbotting violates the Community Guidelines. I cannot help you, sorry.
They eventually meant self.bot...
Let them answer to the question that got asked above
ohhhh that makes more sense
alright i figured out my issue on that;
but now, how can i change a specific members permissions?
How do I get a guild's id and use it
also another thing; would changing every single members permission in a server overload anything?
ctx.guild.id i think
no, like, if i insert an id and how do i use that
oh ok
aight thanks
insert where
already helped him
if i were to change every members permissions at once will that violate any tos?
no
i will get "us"
alright, how owould i change a members permission?
and if i copy it it is just "us"
nvm actualyl
🇺🇸
🇺🇸
what?
is this a good way to route this?
for member in ctx.guild.members:
if not member.bot:
pm = ctx.channel.overwrites_for(member)
await ctx.channel.set_permissions(member, send_messages=not pm.send_messages)
its \🇺🇸
Copy that...
ok
woah
and if i put it in vsc i got this
no reaction appeared in discord
how would i change a members permission and not only for a certain channekl
eh whatever ill do it my old way
sorry idk
wdym by rank names
oh
wait
make a dict of the rank names according to the ints
and then get what the rank int is from the db and then use it to get the rank name from the dict
so if the fetch returns 5 and you define the dict as rankname, you do rankname[5] it should return the rank name corresponding to 5
im hoping that you know how to use dicts
or just save the rank names in the db, idk why you're not doing that, makes it more simple
anyone
import sys
import pygame
def run_game():
pygame.init()
screen = pygame.display.set_mode((1200, 800))
pygame.display.set_caption("Alien Invasion")
bg_color = (0, 255, 0)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(bg_color)
pygame.display.flip()
run_game()
hmmmmmmmmmmmmmmm
my gosh i am dumb
noticed that you are trying to get a rich presence for vsc, theres a plugin called "discord presence" on the vsc extensions tab.
use that instead
np
itll look similar like mine, if you check my acc.
ye
nice
have fun :D
aye @vale wing sorry for the ping but how did you setup that pickle thing you were talkin bout?
from discord.ext.forms import Form
``` don't work.... what I have to do?
What library?
I don't know any that have a forms extension
What do you mean by 'don't work'? Not much to go off there
And you've installed it, right?
so you know the way but won't tell me?
nerd moment 🥸🤧🤡
Why not just use wait_for
That's like saying, why use discord.py? Just make raw requests
how do i create a while loop while my discord bot is running?
o but is there another way other than threads?
if you want to wait until your bot shut down use bot_run.join after all
why you don't like threads
not that i dont like it
I guess you have at least 4 threads
hm
asyncio then
is heroku good to use or is there some better free
I will try that
Does anyone know how to set cooldown for commands, i dont want the cooldown to be shared though
discord py docs for help
i really don't know why many of people here dont know how to goople
google*
The error is happening because data is not truthy, and you set the names variable in there
for not simple help I guess
sometimes its better to ask people in here cause you get live feedback
Its so awkward for me
Its not truthy because fetchall probably returned an empty list or something like that
nah its fine im kinda wrong too i just googled it and easily got the answer
You should set the names variable before you fetchall, then reassign inside of the if statement
Otherwise if it isn't truthy you still have names set,
Ok, i'll try this later
What does BucketType mean
You just set the variable before hand
Set it to a default value and then reassign if data is truthy
The type of bucket, meaning whether the bucket should hold the coodown of a user, channel, guild etc
oh ok thanks
Im making a poll command and whenever I add a reaction to the poll it gives me this error, what do I do? I’m trying to make it to where when you add another reaction it removes the previous reaction you did https://mystb.in/QuestionnaireSufficientPixels.python
well
"message" is undefined
"message" isnt defined*
What?

random
Your grammar isnt correct
Youre*
Why you edited it
Same🤷♂️
Please tell me what can I violate from the Developer Policy if my bot has only functions for music and changing the prefix? This is the second time my verification has been rejected
Music from youtube?
yea, and spotify
!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)
get rekt
Against yt tos
😭
The entirety of your bot violates tos
How do I define it?
how would i know
Why, then, bots like - JuniperBot, botify still working?
why compare other bots
You would be violating discord developers ToS policy b
https://discord.com/developers/docs/legal Scroll down till you see b. Discord DMCA Policy
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Just wondering why then they work if it is prohibited?
Because discord is an amazing platform with the best moderation
thenks
no
Some music bots got shutdown cuz they use yt music which its against their tos
If your bot were to stream copyrighted music that you haven't bought a license for that would break copyright laws
^
Yeah that too btw their very serious laws
Its unlikely you face any serious punishment for doing so
Yeah but if you do make money out of those songs then it is serious
No like from the music
Doesn't mean you should be willingly and knowingly breaking copyright laws
Yeah
Asking the same question again how to restrict lavalink to stop playing from youtube
Anyone please
I want it just to play from SoundCloud and other sources

From lavalink node?
Unless everything from soundcloud you play is not copyrighted you would break the copyright laws
It doesn't matter if its from youtube or any other music streaming service
Hydra uses soundcloud
And unless they bought licenses for all the music they play they are breaking the laws
Just because you see other people do it doesnt mean its ok to do
Well tbh I don't give a shit bout discord
whats RIAA?
!e py word = 'a' l = ['a' , 'b'] if word in l: print('here')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
here
^ use in
i have a function that sends a message in a channel when someone gets given roles how do i stop it from spamming and only have it send 1 message in total for all the roles its being given?
on_member_update checks when a member is updated
i guess keep track of what the roles added in the seconds prior and bunch them up in a single message.
Please tell me where you can find the application ID for discord? To launch activities in the voice channel
I have it, let me get it rq
The snippet you tried to send was too long. Please see #bot-commands for the full snippet.
Wut
Thanks
async def abc(self,ctx, user: discord.Member,who,what, proof , proof2 = None):
How would I take the whole string for "what" and not just the first word? Since its in the middle yk
Basically I want it to read till proof, proof is a link so maybe that could help? idk
just add an asterisk
Hey @slate swan!
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:
GUYS I HAVE A WEIRD PROBLEM ,
when i run my code in vs code it gives me an error, but when i run the same thing in replit the code works , i wanna use vs code pls help...
CODE AND ERROR: https://paste.pythondiscord.com/tecijuqixe.py
that wont work
Open cmd and type ffmpeg
you need to make sure ffmpeg is installed and accessible on your computer
i'm not really sure how one would install it properly on windows, as i'm on linux
i install ed it
which do i choose?
hi
what is the discord.js server link?
i need to get there but cant find the link
He gave you the link and you still ended up being on the wrong place
ffmpeg.org
get the exe file
guyz what is FFmpeg ?
Lmao
cant u click the windows button
hi how do i put my bot into a class that inherit the commands.Bot?
Put it in the parentheses and call super().__init__() in your __init__ method
no thats not what i meant like i mean add @client.command function to the bot
Can you provide some more information?
like this
class Bot(commands.Bot):
def __init__(self):
super().__init__(command_prefix="!")
self.TOKEN = TOKEN
def ping(self, ctx):
await ctx.send("Pong!")
how do i add a command? cause this does not work
oh
yes
so you cant add commands while in class?
it does work on event but not command
mhm
you can use self.add_command()
import
difficult(
no
it's not difficult
make a class
inherit commands.Cog
your __init__ (bot as parameter) function contains only this
self.bot = bot
then you replace @bot.command() with @commands.command()
every bot with self.bot
that's it?
no
okay it's hard I admit
setup function at the end:
def setup(bot):
bot.add_cog(Class_name(bot))
hmm, can't think of any more
load_extension()
yes
in your main file, you'll have to use bot.load_extension(path_to_cog)
wherever or however you want, except in on_ready
so in order for me to be able to connect files and for them to work, I need cogs?
when you're making discord bots, yes
otherwise your Bot instance wouldn't recognise nothing
very difficult((
it's like two languages in one python-discord
no like this
client = commands.Bot(command_prefix="your prefix here")
@client.event
async def on_connect():
print("Logged in as {}".format(client.user))
@client.command()
async def ping(ctx):
await ctx.send("pong")
f-strings
yea you can use those as well
yes
yes
can someone who has used discord-ext-form help me
I'm trying to make a discord bot when someone can do ?name Harry and it will give you the meaning of the name Harry, I have access to the behindthename API and I have an xml and json link and an api key would someone be able to help? Thanks 🙂
okay thx i'll see that
Cool idea, unfortunately I have no experience making discord bots.
decent idea
but idk anything about api's and it seems tricky
im thinking you can list the name
or append the list when it is called with a definition
Nice idea! Would you be interested in working on this for our community bot @lament depot, or would you prefer to keep it a private project? The advantage of working on our bot is you'll get guidance and code-reviews, and in the end members of this server will be able to use the command.
If you're interested, go to the bot's issues page, and select New issue, then Feature. I can't guarantee it will be approved, but I don't see why not. https://github.com/python-discord/sir-lancebot/issues
Yes sure I can do it both 🙂
Hey guys! I'm getting lots of errors when I'm running the code because of discord library. Do you guys maybe know the solution?
uninstalling and installing again doesn't work
whats the code
depends on the issue what can the issue be because it can be based on ur code
discord bot is sorta reliable
I uninstall the library
but then I install the library
it says requirement already satisfied
My code is very long
like 600
can you show the full error atleast?
Yeah, sure one sec
Traceback (most recent call last):
.py", line 3, in <module>
import discord
_init_.py", line 25, in <module>
from .client import Client
client.py", line 33, in <module>
import aiohttp
", line 6, in <module>
from .client import (
", line 35, in <module>
from . import hdrs, http, payload
http.py", line 1, in <module>
import http.server
server.py", line 92, in <module>
import email.utils
email.py", line 1, in <module>
import smtplib
smtplib.py", line 47, in <module>
import email.utils
ModuleNotFoundError: No module named 'email.utils'; 'email' is not a package
whats the packages u isnatlled?
from asyncio.tasks import wait
from typing import ContextManager
import discord
from discord.ext import commands
import random
from bs4 import BeautifulSoup
from random import *
import requests
from random import randrange
import urllib.request
from dotenv import load_dotenv
from discord.ext import commands
from discord.utils import get
from discord import FFmpegPCMAudio
from discord import TextChannel
from youtube_dl import YoutubeDL
import nacl
from discord import Spotify
import googletrans
from googletrans import Translator
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
do u have intents turned on?
If you need assistance understanding the code base, feel free to ask in #dev-contrib.
Not sure what intents are
go to ur devportal and turn on intents in ur discord bots thingy not sure what it is called
turn on member intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
By the way if I uninstall discord library the only error is discord library is missing so I think that it is somehow related to that
I know 🙂
update the package?
Do I need to pip install intents or are they there by default
head over to devportal and find it discord dev portal and enable the setting for it then add the code for the intents
it should help
or update the discord package
When I invited the bot I think I added all the permissions. I'm pretty sure that's not the case. Recently I was working with env so maybe there is a problem somehow related to that
are these turned on? this is intents and can help with the code, my bot is only limited to what it should have think of it like special perms that the bot need along side well admin perms
intents aint permissions xd
should i replace all my bot's prefix commands by slash commands
Yes you should consider that
i have a cog and commands in it. I have functions that i used often so i defined them in static method in the cog, idk if there is a better way to do that
it's an economy cog, so i use function like access_bank, retrieve_money and they are defined in a static method
it's working but idk if it's a good design
class EconomyCommands(commands.Cog):
....
@staticmethod
async def is_registered(user_id):
....
@staticmethod
async def create_account(user_id):
....
@staticmethod
async def get_money(user_id):
....
@commands.command(name="balance", aliases=["bl"])
async def _balance(self, ctx: commands.Context):
...
...await EconomyCommands.is_registered(user_id)..
Have you tried to design it using something like helpers folder and different files for each purpose in it?
no not really because it means you can't ping someone if u have a slash command
if u bot can ping someone
nope, you mean i should do a file for each static method?
No
Make a folder called helper(s), and a file called something like economy then you can use economy.is_registered, etc.
oh i dont like to ping others, that's quite annoying to them
You can.
I'm literally doing it on my bot x)
mmh i'll find out more about this thx
how when i use my bot to ping me if there is a problem i litrally cannot @ them in the command
Sure
@ who/what/why
https://i.krypt0n.co.uk/5247922569.png You can just use this attribute in that library, and use .mention on it
no i mean : /bb command @ usernaem doesn't work the @ doesn't ping the user i mean
Why would you want the user to be pinged
How is that in any way useful and a reason to not use slash commands
TF
lol i dont know what half of those do, they sound madeup
!ytdl anyways
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)
None of them is made up though
Is it possible to get the bot to send a message from one server to another?
Yes
also what does base64 do
He didnt ask for ytdl though
Oh so i put my functions in this economy file then i import this file or these commands in my cog file ?
It contains ytdl stuff
So? It's just ytdl "stuff" he aint asking help for it and the command says we are unable to assist with questions related to youtube-dl
how
I use base64 for shites and giggles but i dont see what it does
get the guild instance then send it
Maybe you want to read that a little bit better and take a closer look at it
hm
on projects that may breach terms of services
Using youtube_dl might lead to YouTube being angry and taking it down.
Not on questions
How can i make this?
Well it is against tos using ytdl but only rythm/groovy have been taken down and I don't think a "small"/"personal" bot like his will get taken down either. 
!d discord.ui.Select
class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.
This is usually represented as a drop down menu.
In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").
New in version 2.0.
Ok thanks
wait is this how you make categories?
is it correct? So it's like the utils folder in the python discord bot?
!d discord.ui.Select.values
property values: List[str]```
A list of values that have been selected by the user.
how to do subcommand
like rpm craft 1, rpm craft 2 in rpm craft
How can i make that the bot say my name not the person i pinged?
Use command groups
ok
thanks
???
ctx.author
thanks :3
its weird
@bot.group(pass_context=True)
async def First(ctx):
if ctx.invoked_subcommand is None:
await bot.say('Invalid sub command passed...')
@First.group(pass_context=True)
async def Second(ctx):
if ctx.invoked_subcommand is Second:
await bot.say('Invalid sub command passed...')
@Second.command(pass_context=True)
async def Third(ctx):
msg = 'Finally got success {0.author.mention}'.format(ctx.message)
await bot.say(msg)
Yeah
what does this mean
For you, you can ignore the second one
second?
@First.group(pass_context=True)
async def Second(ctx):
if ctx.invoked_subcommand is Second:
await bot.say('Invalid sub command passed...')
```this one?
@bot.group(pass_context=True)
async def first(ctx):
# !first / !first second
if ctx.invoked_subcommand is None:
# !first **only**
@first.command(pass_context=True)
async def second(ctx):
# !first second
Whats the exception caused when the has_permissions check failed
!first second
exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
oo
ah ok
i copied that from stackoverflow
nice
thanks
@bot.group()
async def first(ctx):
# this is when you execute !first
@first.command()
async def second(ctx):
# this is when you execute !first second
there
what is !first and !first second
Theres literally nothing called "first" in the documentation what're you trying to do bud
thanks
Then change first to rpm and second to craft
catto you created those commands
rpm is prefix :D
i copied those code from stackoverflow
watttt
yes ik
i need tons of rpm craft (blah blah)
Don't copy if u don't understand what it does
These where off
If rpm is your prefix, craft would be the command and 1 would be an argument
thats why im asking here
im asking what it does here
ok
can't open file 'C:\xxx': [Errno 2] No such file or directory
Error says all
Yeah. Dunno how to fix it though
i think he did it on purpose to not exposed his directory
Give a valid path/file
My discord library does work. I'm getting a lot of errors
Maybe you know what could be the solution
Maybe if you give the errors
yes
=.=
How does your folder structure look like and what is your code
im also wondering
You're probably not importing your files correctly
Well my code is really long. Other imports work
Hmm
Hi guys how would I randomly generate a key value for a dictionary and add it after an if statement is met
I am making a queue system, where players can !queue, once the q reaches 6 players, the game id and user id's are put in a dictionary
{gameid: [user id's]}
but I want game id every time the q reaches 6/6 players, to increase by 1 and thus making a new key with that value
Just the part where you import it :p
Mr. Paper can you show the folder of the file?
Which forlder
folder of the file
Discord bot or imports
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
It doesn't break laws
youtube_dl breaches the terms of service of YouTube
Oh
technically it doesnt but thats a discussion for another day
Ill remove it
using youtubedl on youtube specifically does 
Yeah but who uses it on something else 
me
And which music provider allows streaming?
?
Well, how do you play the music
again, ?

let me introduce you to the concept of a program which isnt a discord music bot
So what's the purpose of youtube-dl in your Discord bot that isn't a music bot?
Again, we won't help you further

in the code
voice_channel = ctx.message.author.voice.channel AttributeError: 'str' object has no attribute 'message' ```py
@bot.command(name="play", help="Plays a selected song from spofity")
async def p(self, ctx, *args):
query = " ".join(args)
voice_channel = ctx.message.author.voice.channel
if voice_channel is None:
#you need to be connected so that the bot knows where to go
await ctx.send("Connect to a voice channel!")
else:
song = self.search_yt(query)
if type(song) == type(True):
await ctx.send("Could not download the song. Incorrect format try another keyword. This could be due to playlist or a livestream format.")
else:
await ctx.send("Song added to the queue")
self.music_queue.append([song, voice_channel])
if self.is_playing == False:
await self.play_music()```
No joke man I just could really use help with discord library
Umm
How can I upgrade discord.py in replit?
my discord bot?
when did i say it was a discord bot?

How does using youtube-dl not breach their terms of service when not being used on Discord
How do you use youtube-dl in your project so that it doesn't break their terms of service
anyone
I don't use youtube dl !!!!!
Not talking to you
voice_channel = ctx.message.author.voice.channel AttributeError: 'str' object has no attribute 'message' ```py
@bot.command(name="play", help="Plays a selected song from spofity")
async def p(self, ctx, *args):
query = " ".join(args)
voice_channel = ctx.message.author.voice.channel
if voice_channel is None:
#you need to be connected so that the bot knows where to go
await ctx.send("Connect to a voice channel!")
else:
song = self.search_yt(query)
if type(song) == type(True):
await ctx.send("Could not download the song. Incorrect format try another keyword. This could be due to playlist or a livestream format.")
else:
await ctx.send("Song added to the queue")
self.music_queue.append([song, voice_channel])
if self.is_playing == False:
await self.play_music()```
why are you pasting code here? if you want help say something that will explain the help you want
You are not in a cog
Remove self from the parameters list of the command
okey
because everyone asking me "Send code"
And I don't know what search_yt does, but if you're using ytdl you shouldn't ask questions about it -> #rules 5
shiiiiiiiiiiiii
i delete
but voice_channel = ctx.message.author.voice.channel AttributeError: 'str' object has no attribute 'message'
@bot.command(name="play", help="Plays a selected song from spofity")
async def p(ctx, *args):
query = " ".join(args)
voice_channel = ctx.message.author.voice.channel
if voice_channel is None:```
Have you restarted the bot?
ctx is a string?
yes
a
Are you in a cog?
i delete
What is lastest version of dpy?
Are you in a cog?
no
2.0
1.7.3 - normal
2.0 - beta
song = self.search_s(query)
NameError: name 'self' is not defined```
Well as I said
You're not in a cog
So you can remove all the self.
And not copy paste code from other sources
As you will face undefined variables/functions errors pretty soon
okey
how can I use dpy 2.0?
To install the development version, do the following:
$ git clone https://github.com/Rapptz/discord.py $ cd discord.py $ python3 -m pip install -U .[voice]
found
clone?
pages?
Pagination
ye
cuz chat is being spammed with items in shop
any way to make pages the easy way?
I mean it depends on how you want it to be
like this
but when theres above 12 items in shop
then u must do ,shop 2
to send page 2
how abt
1st page is Category (Ex: Electronics)
2nd page is Category (Ex: Other)
I bet I would be able to buy myself a nice laptop if I get a dollar whenever I answer how to install dpy 2.0 😂

😦
or maybe
Not saying anything to you, but people are just confused about that since it's not available to install, the main way (pip install way)
XD
Help.
group commands
bruh make another
then how i am gonna buy items from mainshop2 for example?
group commands and make others command in group like shop 2 shop 3
hey can someone help me resolve an error which spyder throws when i try executing a bot
Exception in callback <TaskStepMethWrapper object at 0x00000201AE3F3AF0>()
handle: <Handle <TaskStepMethWrapper object at 0x00000201AE3F3AF0>()>
Traceback (most recent call last):
File "C:\Users\lol\anaconda3\lib\asyncio\events.py", line 81, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <ClientEventTask state=pending event=on_ready coro=<function on_ready at 0x00000201AE3BBDC0>> while another task <Task pending name='Task-2' coro=<Kernel.dispatch_queue() running at C:\Users\lol\anaconda3\lib\site-packages\ipykernel\kernelbase.py:457> cb=[IOLoop.add_future.<locals>.<lambda>() at C:\Users\lol\anaconda3\lib\site-packages\tornado\ioloop.py:688]> is being executed.
i use anaconda btw
just help him
Is the "news channel" in TextChannel.is_news() just an announcement channel
thank you
anyone know any good open-source discord bot ranking systems in python
property voice: Optional[discord.member.VoiceState]```
Returns the member’s current voice state.
and use .channel
voice_channel has been removed from a long time , are you watching some tutorial?
okey
yes old video
so like