#discord-bots
1 messages · Page 599 of 1
secondly, its not working because when I do !stats, its not showing my own stats
however the !stats @ user is working
Print info
hi i wanna do this :-
for example someone adds my bot in their server
and there is a join log in my main server
for example
WE JOINED PYTHON server```
Gaah I'm on phone I can't understand shat
Give me a sec
Ty
You might have used tab instead of space or vice versa and your IDE did not automatically change it
also this code do not send the info
Iirc {guild.name} for the guild name
Its not the full code
@bot.command(pass_context=True, name="stats", description="Check your 6Mans stats")
async def stats(ctx, player:discord.User = None):
if ctx.channel.id in allowed_channels:
if player == None:
pid = ctx.author.id
info = pstats.find_one({"id": pid})
else:
pid = player.id
info = pstats.find_one({"id": pid})
if info is None:
embed = discord.Embed(description="You have not played a game yet!", color=0xE74C3C)
embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
await ctx.channel.send(embed=embed)```
This is based on the code you sent. I fixed the indentation error
am confused idk wht to do X_X is there some code for it?
You want to use the on_guild_join event
Read up the docs on it
Oh wait, thats why It wasnt printing for my own stats
okie x_x
because it was just under else
yea thats what we are saying
Coding on phone is a big nono sigh
My bad, i didnt realize you could do if else if
I am still on phone ;_;
My ass would have just pasted if info is none code under each
You should get the channel id where you want to send the logs and then you send the msg await bot.get_channel(int).send(f"joined {ctx.guild.name}")something like that
Horrible coding.
I'm learning.. slowly 
you can do this with webhook also
its easier
Just remember
Repeat code == veri bad.
I'm assuming they want to know how to "know when my bot is added to guild" part 
by the way @full valley you dont need pass_context
i see , how may i know? :))
hmm i see
Ty once again.
Yeah
When do you need it?
That's uh
you dont it isnt needed anymore
yea I guess
Well yeah but that won't work
Gods I just want a laptop in my hands now
@bitter harness https://discordpy.readthedocs.io/en/stable/api.html?highlight=on_guild_join#discord.on_guild_join
The event^
okie 😮
If i do !stats (id of another member), it doesnt work, just gives me my own stats
also remember this
you dont want a lot of nested shit
it should work
if x is this:
print(crap)
do(crap)
```or or or ```py
if x is not this:
return
print(crap)
do(crap)```
Do you have members intents?
And does it need it?
not needed
Why is that so?
they are just accessing public info(snowflake id) of a particular mentioned user
and fetching data of it from their own db
I can !stats @ mention other players, but not use other players id's
I see
you can use their id too 
Well ive tried it
in my bot (different command but same target) it works
player:discord.User = None
the :discord.User part tries to convert the mentioned/id to a discord object 
try printing pid before info =
@full valley
and then try !stats id?
yup
Are there any ideas for utility command : which no popular bot has?
yeah so its printing the right id @slate swan
but is it a string, instead of an integer or something
in my bot, this is working completely fine
ah i got it
pstats.find_one({"id": pid}) tis find_one wants id as int, am i correct? @full valley
just pass int(pid) into it 
yea thats also right
Did not work 

@full valley run this piece of crap
https://paste.pythondiscord.com/areyaviran.py
i just cleaned your code itself a little 
try printing info too btw 
Command raised an exception: UnboundLocalError: local variable 'info' referenced before assignment
@slate swan

wait im an idiot
thats my bad
print(info)
info = pstats.find_one({"id": int(pid)})
LOL
also
wtf is this crap
why dont you just do name="Wins", value=f"{info["Wins"]}", inline=True
fyi that is not my id
true

it looks like a problem with get_one
its printing the right id but getting the wrong info 
yeah
does info print the correct info for id @full valley ?
yep
{'_id': ObjectId('6193644878c4593b498bd45e'), 'id': 606022210573959179, 'Wins': 0, 'Losses': 0, 'MMR': 1600, 'Rank': 'C'}
well what the fuck
and those are not your stats 
Those are everyones stats
but that is not my id
ah.
what if
ayo
you are using value=ctx.author.mention even if id is not none


How to check if bot has permission in a "channel"
like we use guild.me.guild_permissions.send_messages
!d discord.TextChannel.permissions_for
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
hmmm
I changed from discord.py in pypi to discord.py in github but there's some bugs in code because of this change
Okay?
in discord pypi we can use from discord.ext import commands but now I can't
hmm idk how to fix it
it's "can not import commands from module discord"
hmm
maybe it's path error?
let me see
agh yes path error
but there's a new error
My bot: (I'm newbie)
import os
from discord.ext import commands
import discord
from dotenv import load_dotenv
from discord import Member
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions
import random
import asyncio
load_dotenv('DISCORD_TOKEN.env')
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix=';')
bot.remove_command("help")
@bot.event
async def on_ready():
activity = discord.Game(name="A game", type=3)
await bot.change_presence(status=discord.Status.online, activity=activity)
print("Bot is ready!")
@bot.command()
@commands.has_permissions(ban_members=True)#bans members if admin role is true
async def ban(ctx, user: discord.Member, *, reason="No reason provided"):
await user.ban(reason=reason)
ban = discord.Embed(title=f":boom: Banned {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}",color=0xB026FF)
await ctx.message.delete()
await ctx.channel.send(embed=ban)
await user.send(embed=ban)
@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
await user.kick(reason=reason)
ban = discord.Embed(title=f":boot: Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}",color=0xB026FF)
await ctx.message.delete()
await ctx.channel.send(embed=ban)
await user.send(embed=ban)
@bot.command()## get mentioned users avatar
async def av(ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)
@bot.command()##help command
async def help(ctx):
em = discord.Embed(title="Tutorial Bot command list:", description="", color=0x2f3136)
em.add_field(name="`;ban {user}`", value="Bans the user.")
em.add_field(name="`;kick {user}`", value="Kicks user.")
em.add_field(name="`;av {user}`", value="Gets the mentioned users pfp.")
em.set_footer(text="Krise Alumine")
await ctx.send(embed=em)
bot.run(TOKEN)
the bug is:
[ ...Many traceback... ]
from .bot import *
File "/private/var/mobile/Containers/Shared/AppGroup/162FBE5F-D295-49F2-AA76-1963F27DA4B8/Pythonista3/Documents/site-packages/discord/ext/commands/bot.py", line 25
from __future__ import annotations
^
SyntaxError: future feature annotations is not defined
In modules of new discord.py
hmmm
wait?!!
it's version error again?
my python ver. is 3.6.1
How you all get dpy 2.0
pip install -U git+https://github.com/Rapptz/discord.py
it has some breaking changes
"""
While you can install discord.py 2.0a, Danny doesn't recommend it, since it has breaking changes, and drops support for older version of Python. Regardless, if you want to install it, just do it like you normally will from Git. https://github.com/Rapptz/discord.py
This has breaking changes, so expect bugs to occur as well as features to change or become deprecated.
"""
3.8 +

yes dammit
I have only a iphone and Pythonista, and now it's using Python 3.6.1
_:(´ཀ`」 ∠):

there's no way to build a bot
anger Error: Command raised an exception: AttributeError: 'PrettyHelp' object has no attribute 'clean_prefix'
Fails on dpy 2.0 only
depends which tutorial you are using and which api you are using 
Any help
ask in dpy server beta testing #669155775700271126
I got perm muted there
Lol
wonder why
Using exploit to avoid temp blocks for help channel
well figure out for which api its using that token and get your own token for it
Guys a lapsus, how i make the bot so it works only for one guild?
you can use errors for checking like
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.errors.CommandNotFound):
await ctx.channel.purge(limit=1)
the thing is it only works with message that starts with the prefix of your bot
An "API token" is something you need to access an API (like a password of sort)
you can check for the message content to see if its "something" you want and then you could delete it I guess
if message.channel.id == ...:
await message.delete(message)
public_flags = {
"bug_hunter": "",
"bug_hunter_level_2": "",
"discord_certified_moderator": "",
"early_supporter": "",
"early_verified_bot_developer": "",
"hypesquad": "",
"hypesquad_balance": "",
"hypesquad_bravery": "",
"hypesquad_brilliance": "",
"partner": ""
}
if member.public_flags is None:
yourPublicFlags = "None"
else:
for badge in member.public_flags:
print(badge)```how do i display member's public flags using my own emojis
thing is idk how to continue after the for loop
channel id needs to be int btw
yeš
make a list, then loop through member.public_flags, then see if the value of the elem key in the dict, append it to the list
and that verification system is very easy to bypass
When I try to add a role to all channels and issue permissions, this error appears
overwrites kwarg accepts Mapping of [Role | Member, PermissionOverwrite]
not directly PermissionOverwrite
How to do it directly?
for @everyone role?
No, I am removing the mute role from the database and I need to add it to all channels
so?
yes
nu , it must just be discord.PermissionOverwrite object
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
overwrite.read_messages = True
await channel.set_permissions(member, overwrite=overwrite)
``` example from the docs
Hello i have a question so i made a wikisearch commands with wikipedia.py
here is my code :
async def wiki_search(self, ctx, *,question):
def wsearch(self, arg):
wsearch = wikipedia.summary(arg, sentences=5, chars=500)
return wsearch
wembed = discord.Embed(title="Wiki search", description=wsearch(question))
await ctx.send(embed=wembed)```
i run it with ?wiki amd and get error :
```TypeError: wsearch() missing 1 required positional argument: 'arg'```
When you invoke the command you have to add a question as seen in your parameters so it would be wiki_search MyQuestion
read your own code 🤦♂️
anyways it looks like you didnt enter anything at question or its a parameter issue
Oh so wiki_search Question (...) Like that?
I think the arg was the question 🙂
Just wiki_search Question
yes I see you using it
wheres this supposed to go oh the command?
Uh i had no idea
I mean to start the command it must start with a arg but i looks like hes the parameter question and then passing it as arg in the function inside of the corountine
you dont need to codeblock everything
I like them tho😔
So i need to my def wiki_search to another name thennmy wsearch = wiki_search question?
Just change the name of the parameter question to arg
Yw
whats mute_role
This role is installed by the owner of the server for the mutation of participants, and I get this role from the database and want to add it to all channels
pretty sure you get only the role id from the database , do you use guild.get_role(id) to get the role object?
works decently for me
ohhh wait py for guild in self.bot.guilds: for channel in guild.channels:
so basically what's happening is , the bot tries to edit a channel for a role that is not from that server
And how, then, to solve the problem?
just remove the for guild in self.bot.guilds....
and use a guild object to which the role belongs
so?
ohh ,dict has not attribute channels
It's worked, thanks you so much
How to make the date show as in (de_DE)
So that the day goes first, then the month and the last year
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
why do i keep getting this error
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
you did too many api requests
are you using replit?
@glass rock
- They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
yees
nah i just started day before yesterday. Does replit cause the errors? What alternatives do you suggest?
A proper IDE.
ty
How do i add a illegal character to a str?
???
Like how do i add double quotes inside a string
!e
print("what illegal characters? 'this'?")
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
what illegal characters? 'this'?
🤨
print(""hi")
invalid syntax
print("im a string "hello"im a string")
@slate swan
!e print(""hi")
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
"hi
oh
Thx
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
hi "hi" "hi"
Ok thx
@slate swan halp am trying to connect a time api and i.... need help
here in the datetime i need to retrieve 2 digits
but dunno how to
halp
The text of the error. Could be an empty string.
there
hm is it for me?
no
ok..............
2 digits from?
the json data
ex.text
{"abbreviation":"IST","client_ip":"115.97.36.3","datetime":"2021-11-16T18:46:01.325874+05:30","day_of_week":2,"day_of_year":320,"dst":false,"dst_from":null,"dst_offset":0,"dst_until":null,"raw_offset":19800,"timezone":"Asia/Kolkata","unixtime":1637068561,"utc_datetime":"2021-11-16T13:16:01.325874+00:00","utc_offset":"+05:30","week_number":46}
this is it in this i need to retrieve the datetime
then what do you mean by 2 digits
the thing which i bolded
the 18 i need to retrive that place
em=discord.Embed(title='Error!', description=f"{error}.", colour=discord.Colour.red())
# em.add_field(name=f'Failed exception:', value=ctx)
await ctx.send(embed=em)```
here my error handler
json["datetime"][-2:]
oki TYY lemme try
for missing permission raised from HTTPException, you cant
well what did u try to do
this was the data
and from the data i highlighted the 2 digits
why
i want to retrieve that
do u even need the 2 digits
those are the hours , im making a change_pfp thingy
hm
just make a loop
i mean i can make it with tasks but the timing must be perfect for the server people
;-;
yes
use a loop?
can ya help this poor bot guy
lul use normal cmd tbh
async def change_pfp():
# responseTimezone = requests.get("http://worldtimeapi.org/api/timezone/Asia/Kolkata")
# data = json.loads(responseTimezone)
# response = data['datetime']
# response1 = response
with open('night.png', 'rb') as image:
if client.user.avatar == image:
with open('sun.png','rb') as image2:
await client.user.edit(avatar=image2)
else:
with open('night.png','rb') as image:
await client.user.edit(avatar=image)```
u cant tell what permission needs to be enabled if u want that make normal command errors
a task?
yes
slash command handlers are......... idk read the docs ig?
@bot.command()
async def roll(...):
...
@roll.error
async def ...(...):
...
```this is a command error
shit lib
use a proper fork thats not one designed to be used with dpy
forks have easier syntax
nice
Now whats your error again
yes
disnake, pycord, nextcord (beta iirc) etc
is this getting raised when ur doing slash commands
ah
you need the application.commands + bot scope in your bot
re-invite it with the scopes
hm does ur bot have perms
ugh
Whos name did u try to change
nice
show code
afk command
hm
well
it looks like
- bot didnt have permissions
- bot didnt have a certain scope
- hierarchy
try-excepts
halp
it isnt working
dont think u can in discord only in the developer portal
hm
or more preferably a check + error handler
you have the bot perm check in there too, you just havent specified any permission to check
how do I get all the messages in the bots cache?
very nice
replit db suck
hm ok
not like its illegal or anything 🤨 😌
i need suggestions for database
sql, mongo
oki
i think
you think what
so you need a replit database?
we are talking about replit?
since its public
Is sql lite a good database module for discord.py???
yes
proper IDEs are private
Still almost any ide is better than replit
ikr
yes, but use aiosqlite
people use replit just because its free hosting
What is that?
am not using any bank details lul
Yeah but its not great either
mhm hacker plan feels good
async version of sqlite
Ohhhhh
why wouldnt you buy a vps for the cost of replit premium?
shrug
¯\_(ツ)_/¯
A vps is better than replit premium tbh
replits already trash and your giving it even more money
🤷♂️
ofc
help
@commands.command(name="настройки")
async def settings(self, ctx, *, value=None):
if settings == "авто-роль":
if value == None:
embed = disnake.Embed (
title = ':x: Ошибка',
description = f'>>> Ты должен(на) указать 1 роль которая будет выдаваться автоматический.',
colour = 0xff6c66
)
embed.set_footer(text= 'Барабан4ик © 2021 Все права у тянок', icon_url= self.owner.avatar)
await ctx.reply(embed = embed, delete_after= 20)
elif len(value) >=2: #There's a problem here
print(len(value))
else:
role = value.replace("<@&", "").replace(">", "")
embed = disnake.Embed (
title = 'Авто роль:',
description = f'>>> **Установлено на:**\n{value}',
colour = 0x694c5f
)
embed.set_footer(text= 'Барабан4ик © 2021 Все права у тянок', icon_url= self.owner.avatar)
await ctx.reply(embed = embed)
guild = ctx.guild
self.collection.update_one({"_id": guild.id}, {"$set": {"auto_role": int(role)}})
he writes that there are 22 words in the line and there are 1 of them there
What I write in the argument: <@&ROLE>
but how do i host 24/7 freely
\🗿
Just buy a vps replits free hosting isnt good at all
what?
true as soon as i get my own moni , its raining host
hmm
How much is it for a month like the lowest plan i havent checked it out yet
idk either
i m still using the trial
(and i dont want to pay either nor i want to know the cost)
Digital oceans is 5 bucks a month for the lowest plan
???????
i will never forget that day when i saw a utube tutrl to make a cmd and was so happy the bot responded
How to do something like global unabn command
u need to add it in json file,the bans ,and yes
Same
i was freaking out......... i know javascript but its hard to make discord bots in that
You felt like a genius when the bot printed it was online lmao
it isnt
help me
Felt like you were anonymous or something
pls wait
you just need to be good in javascript to make your bot respond
Ok now your flexing
djs generally has the same syntax/naming as dpy
🤷♂️
iirc message.content is messageContent in djs
It's also message.content.
Seems weird to me how its not separate by a .
🤔
.
It's pretty much very same. A message is also a discord.Message object, and so is member and multiple other things.
Me who adds 3 m's in command decorator
lmao
Its always saying Bot doesnt have a attribute with commmand😭
Because it's commands and not command
wut
its Bot.command() , they just have m thrice
i think
it doesnt need to be
yea
Yeah😭
im super new to python and coding but im trying to do make a bot where if the correct string of words are entered they get a good response. If the member doesnt enter that correct response they get a premade message random that flames them. I can get the message to send for the right answer but the random message is beating me up.
Use the module random
import discord
import os
import requests
import random
from keep_alive import keep_alive
client = discord.Client()
message = [
"'Oi! Look at this loser here!'"
"'YOU DAFT PRAT'"
"'Better luck next time… NOT!'"
]
@client.event
async def on_ready():
print('You have logged in as {0.user}'.format(client))
called whether there is a message in the chat
@client.event
async def on_message(message):
if message.content == 'scar calico hoodie wink':
await message.channel.send('You cracked the code🔥 Only the first one to get this wins.')
else:
await message.channel.send, "{}".format(random.message(message));
keep_alive()
client.run(os.getenv('token'))
hello. can you change the discord bot permissions later.? like i dont really know what permissions to give the bot and if i miss something can i add later?
admin
you can always change discord perms
camel casing
Just add admin perms in the devportal
?
?
In your bots scopes add admin perms and re-invite it
ok
To get a random item from a list what you have to do is random.choice(customlist)
would this look right?
else:
await message.channel.send, ~~"{}".format(random.message(message));~~random.choice(customlist)
Not quite
How do I find the guild id without using ctx
if its not in a function
is it discord.guild.id?
More like:
message.chanel.send(f"{random.choice(phraselist)}")
No need for .format if the list doesnt have a int
im using replit. would i have to create the random file or will it pull it automatically
Just make a list and from the list you get the phrases
Would this work:
def getserverid(ctx):
gid = ctx.guild.id
return gid
guildset = settings.find_one({"guild_id": getserverid()})
qsize = guildset["qsize"]
Yeah but change the name so it wont be the same as the message object
so variable would work since its nowhere else in the file
A list and any corountine can see it because its a global list
new bug is now its now repeat messaging
Show the code
import discord
import os
import requests
import random
from keep_alive import keep_alive
client = discord.Client()
list = [
"'Oi! Look at this loser here!'"
"'YOU DAFT PRAT'"
"'Better luck next time… NOT!'"
]
@client.event
async def on_ready():
print('You have logged in as {0.user}'.format(client))
called whether there is a message in the chat
@client.event
async def on_message(message):
if message.content == 'scar calico hoodie wink':
await message.channel.send('You cracked the code🔥 Only the first one to get this wins.')
else:
await message.channel.send({random.choice(list)})
keep_alive()
client.run(os.getenv('token'))
You have to make them different strings by adding,
if message.author == client.user:
return
yeah i just caught the commas
Oh yeah that to i forgot hes using discord.Client()
(:
@winter moth add this to the top of your code and not in the corountine
Doesn't really matter but its better
He should add that inside the on_message...
🤷♂️
.....?
Nothing
do that below the @client.event
No inside the corountine
Below:
async def test(ctx):
No under the @client.event
@client.event
async def on_message(message):
if message.author == client.user:
return
besides the {} printing in the messages which isnt a thing this is perfect
Are you accessing a list? cause all you need to do is just index that list
I would just check with
if message.author.bot
^
So that all bots get ignored
that would be ideal. Unless you're like me and make a bot that commands another bot 😂
its in a channel that only members with a certain role can access and bots are denied access
Sadly Dyno ignores bot commands 😐
Hi guys how can I access the guild id of the server without having typed a message?
can you show your code?
You need to use get_guild or something
I kinda wish all that was camel cased like in JS
#Global variables
x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
playerqueue = []
lobby = []
games = {}
allowed_channels = [892691480228020235]
allowed_sizes = [2,4,6,8]
#!qsize command -> Changes the guild prefix
@bot.command(name="qsize", description="Change the queue size")
async def qsize(ctx, size):
if ctx.channel.id in allowed_channels:
if size in allowed_sizes:
settings.update_one({"guild_id": ctx.guild.id}, { "$set": { 'qsizq': size } })
embed = discord.Embed(description=f"The queue size has been update to {size}", color=0xE74C3C)
embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
else:
embed = discord.Embed(description=f"Please use a valid size (2,4,6,8)", color=0xE74C3C)
embed.set_footer(text="CBell 6 Mans | Created by Heptix", icon_url="https://i.imgur.com/1utxX7d.png")
await ctx.channel.send(embed=embed)
if message.author.bot:
return
if you do that you can remove the two lines above it.
So I want q size to =
x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
but I cant just get the guild id
It looks like something with your query because in a command, ctx.guild.id does work.
yeahh but its not in a command
@brittle ingot @slate swan @slate swan Thank you Thank You Thank YOu for all the help
@bot.command()
is a command decorator and its inside of it...
oh i see
yeah u get what I mean
Glad to help
i was looking further down. In that case i would make it a standalone function with a guild parameter. That way you can call it in your bot command.
use
if message.author == client.user or message.author.bot:
return
something like updateQueue?
Hmmm wouldnt have a clue how to do that
Hey NVM me interrupting but can I DM you
@brittle ingot
a bot.command is a function just that its assigned a decorator so the code knows its a command. something like:
async def getQueue(self, guild):
x = settings.find_one({"guild_id": guild.id})
return x["qsize"]
I just wanted to ask bout your guardian system
its not up yet
any way to trigger the discord bot when data from webhook arrives ?
Oh what it is tho?
Not using classes.. but where would the guild argument get its value from
ints have no attr id
who said it was an int?
plsss
ahh so you would just remove self then and wherever you need that qsize sent you would just call it.
qsize = await getQueue(ctx.guild)
Edited original to reflect this.
a webhook event?
only ctx.guild
Yeah but can I use that if qsize is a global variable?
is it more than one server?
otherwise you will need to get the guild from the cache?
Not, but ive set it up so it can be
So if you want it to be more than one guild, even if you only want one guild. This code isn't self updating as a global variable:
x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
As i understand it this is your way to change the guild prefix? You will want a way to fetch the updated list. Which would require some sort of function as far as i can see. I could be wrong though
also here, qsize is spelled wrong, dk if that is intended or not.
settings.update_one({"guild_id": ctx.guild.id}, { "$set": { 'qsizq': size } })
I'm basically just trying to have a global variable 'qsize', and then users can change that variable, but it is stored in my mongo db
but yeah that was a typo, it is 'qsize'...
So if you store it in your mongo Db you can access it everytime you want without much consequence just like you would with a local DB.
right
x = settings.find_one({"guild_id": ctx.guild.id})
qsize = x["qsize"]
``` is finding the qsize variable in my mongo db
ok i think i understand now. So that is finding the current variable to be used throughout your code? If this is the case i would stick to my original recommendation where you have a function that gets called when you want that qsize. That way you are always getting the most recent version of the qsize.
so as example, function would be:
async def getQsize(guild):
x = settings.find_one({"guild_id": guild.id})
return x["qsize"]
Then to access it you would call the function for instance in a command:
@bot.command()
async def qSize(ctx):
qsize = await getQsize(ctx.guild)
await ctx.send(f"Current qsize is: {qsize}")
getQsize doesn't need to be async ^
true
wait but wouldnt that only work if someone does !qSize
You can see I use the qsize variable in my queue command
e.g. if len(lobby) == qsize
So im really just trying to update the global variable here with whatever value qsize has in the data base
if you are fetching the settings again, cant you just get the qsize from that? with qsize = ggid["qsize"] or is that a different collection
Yeah I guess you are right same collection
so I just define q size in the command function
instead of global
yeah if you are get the setting within the command function you can do it right after you get the settings.
plus i wouldn't advise creating many global variables as it gets confusing.
right so:
#!q command -> Puts players into queue
@bot.command(name="queue", aliases=["q"], description="Join the queue")
async def queue(ctx):
if ctx.channel.id in allowed_channels:
ggid = settings.find_one({"guild_id": ctx.guild.id})
game_id = ggid["game_id"]
qsize = ggid["qsize"]
pid = ctx.author.id
pmention = ctx.author.mention
if pmention in playerqueue:
embed = discord.Embed(
...
looks good to me
I get what you were trying to do and it was right for a more complex application but i think for this i don't think so 😄 good luck
ty!
Hello guys, maybe anyone know or there is a bot who can moderate the channel? i have problem always someone hacks my admin/mod acc and kicks all members. I want to add bot for example if person kicks or bans 10 players in a row it auto bans him.
Well make one yourself
Preety simple IG
And I found this bot
https://top.gg/bot/651095740390834176
"hacks"?? Or do you got a password like this?1234
lmfao 1234
The password of the year award goes to 1234 😂🤣
Yeah lol accounts don't just get hacked.
You can't ban someone that can ban
This is wrong.
You can sir
Depends
😂🤣
Hierarchy
change it so they cant ban, then ban
The banning bot's role should be above than the target member's role
He said admin so probably its the highest
That or get more trustworthy mods/admins.
In some servers Admin is a role lol
and make sure they have 2fa
Get lastpass today
Yes and thats wht i said its probably highest
No adverstising
Just keep the bot's role above the admin role
Simple
Not the best thing you could do either
@cloud dawn no there is some hackers who steal discord dev tokens, they even bypass 2ffa.
Or pass the ownership to bot
Tokens can bypass 2fa
they steal everything even chrome cookies 😄
Why do you even run such grabbers
I've heard about applications that take discord token, but still then your staff isn't alert. Usually it's people that give money to try out their "game".
Don't you guys think it's not a coding related issue?
i dont run, i talking about my staff members, i never been hacked. but there is some reg ppl who get hacked always.
Kick those staffs
Simple
¯_(ツ)_/¯
Big brain moves
If someone doesn't know what applications are faulty and get easily tricked i'd recommend that aswell.
If your staff wouldn't go to robux.free.generator you would be fine🤷♂️
Unless it's on a site ofcourse, then you can try all you want.
Yup staffs should be somewhat experienced and intelligent unlike me
And active*
Hmm nitro generators are fine right
I am using one
jk
jk
jk
idk 2 times my discord got hacked first time all members banned, now i got ppl back and again all members kicked. moderator did that.
The lesson is to never download a random exe. File you see on the internet
I haven't had a anti-virus in over 4 years, even forced de-activated windows defender. Never had a virus or malware. Sometimes ran a scan then uninstalled it again- no result.
lol
Just don't download sketchy stuff and you will be fine thats all mostly
Any file can be malicious if the effort was being put into it.
Just get some smart staffs
Yeah but i just said exe. For the fun of it
I use Linux 😎
Yep lol
xD
I can hear exe files crying in the corner😂
This is exactly the reason why i code malware for unix based sytems.
||joke||
😭
so youre saying i need to start changing all mine
I have a custom image of Kali Linux
Or is it?
lol yes

Haker moment
Well have a good long password for thinks like google or other sensitive application. And remember: sentences are the best passwords.
I use Kali Linux and Windows 11 on dual boot
And Parrot OS in VM
jtf73wt5834tjhewbfopidjvlefgr\es\gersgaerh
Is it a good password??
No more signs
Is parrot OS a cloud based vm?
Like:
Yourmomismygf
I use it in VMware😀
Would you even remember that lol.
Lastpass my old bro exists.
Oi sir be in your limit
I don't really want any 3th party password manager to have all my passwords.
Thats a strong password like our relationsh.....
Yeah
...........
Like my relationship yes.
No the relationship between your mom and i son

Well I don't see any problem in that
Lastpass is preety secured
Nothing is more secure than your own brain.
Ok be serious no mom
New password for my Gmail - your own brain
||mom||
Noone answered my question or there is a bot to manage moderators, for example if moderator kicks 10 players or 10 it gets auto ban.
@woeful thunder Answered already
But you ignored
Yup but I suggest making one yourself
Yes and make all of those bots into one 
Never seen a bot that bans if you ban x amount of times in a row in x amount of time.
Me either🤷♂️
Yup that's why make a bot yourself
It's pretty easy though when using on_command_succes
Making an anti nuke bot is not really hard
Agreed.
Or just be responsible and remove that staff member and moderate your own server
Scary easy
Yup the best solution
Its hes own server afterall
I think this is harder since you also need to keep in mind the rate-limiting and the structure.
I can send the code here rn
I made one just for practice
Goodpoint
Not allowed.
Or was it?
You got a point

I am jk man
Or was he
Why would I make something like that
Some aren't lol
Why would you
Well i don't know you..
Sir I am not interested in nuking servers
Selfbots are interesting tho
or are you
Nuke bot is shit
.......
selfbots are pretty nice, but some people ruined it for everyone by abusing the API and ruining servers.
I swear I never made a nuke bot
Yup I request discord to make an endpoint for selfbots only
With more rate limiting maybe
||c|| ||a|| ||p||
...........
Significantly more.
Yes
FR they should do that
Cuz idiots like us are gonna make selfbots no matter what
It's better if it's legal
"like us"?
I went to prison once cause of selfbots
Good description
LMFAO
I made selfbots earlier but now they are boring
im not joking
Cuz my friend got banned💀
Which jail?

who is okimii
I always follow Discord ToS, i don't see a reason to break it. If you want to listen to music with friends use Spotify and what would you ever want to automate on your Discord account?
you mf
Maybe spamming my gf?
Imma kill @slate swan
Whos that
you
Whos that
The guy who is being replied
Are we still talking about something Discord related..?
Are we?
maybe
MAYBE NOT
You asked for a good reason to automate someone's account and I replied
To spam my gf
Spamming is not really a good reason.
BAHHA atleast I can see that cute smile on her face
Use pyautogui its not against tos
Use selenium instead
That is exactly why the ToS says in any way
And I don't wanna host it on my machine
Is this a discussion related to Discord Bots........? Doesn't seem like one to me
Maybe IDK
I love discord bots
It's a discussion about Discord selfbots
:tos:
I love Discord Bots
I hate Discord
As if we are doing it lol
trust it isn't 
The only way to convince Discord if you'd build your own Discord selfbot gf AI
Tried it bro😔
Erza Scarlet
A cheap shit chatbot who can become your gf
Make that now
WTH does that actually mean
Discord selfbot gf AI
Do it youll become a billionaire like bill gates
At this point just hire a gf on fiverr
Me is happy with my one penny in my pocket
They aint cheap bro i checked
🤷♂️
Jk
Or tinder
||or am i||
What do you search..??
What dont i search

https://gfrental.com/
You need this
Or just make your own website and code so you get the best females
Already have it
LMFAO this guy got some brain
there are ot channels FYI
okimii is smarT
Ofc i do i work for bill gates
perhaps we could keep this chat dedicated to the name of this channel.
Yes
is it possible to track usage by a specific user without checking it in every million event
Back to topic now
goes to my gf
What do you want to track?
Well no you'd prob need like 6 to 8 events to do that
prob even more.
Why though..?
Makes sense
im giving account access to a friend so we can stream a video using this accounts nitro and his network speed 
dont ask why
So basically you want to track all inputs of a user?
correct.
Well idk😔
But you're seeing his screen..?
I just recommend not doing it, only if you really trust this friend...
You would be server restricted anyways, he can just DM or hop to another server.
We don't recommend anything that goes against ToS.
So it's best to just not bring it up.
I said that in the 2nd line
You really are a criminial on the run
lol
If your trying to see everything your discord account is doing i dont think its possible
d.py doesn't support self-bots fyi
It does
Stable version does.
The master branch doesn't
Whats that?
When talking about a package when not referred we're always talking about the stable version.
i mean yeah but you won't be able to access a lot of things as far as I know
The pypi version
Ohhhh yeah
Well he meant the master branch
not really
.
For example?
Ok everything that involves priviliges intents won't work IK
yeah
But for most of the work you don't need them
Most people self bot for their status
I don't think many people use selfbots to get roleinfo lol
Not really
I use selfbot to spam my gf
I'm not talking about role info
guild related information is pretty useful
I just gave an example
i made a welcome command but it sends the message when users join a different server with the bot too, how can i fix it?
Get the guild id
hm okk ty
Yw
@bot.event
async def on_member_join(member):
if member.guild.id == YOUR_GUILD_ID:
... # Send the message
tyy :D
it workedd tyyyy
any1 know how to add quotation marks in text
@cloud dawn have you seen such a chat before
looks like a lot of webhooks to me
Yeah it is lmao
bot = commands.Bot(command_prefix= '$')
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
class SomeCommands(commands.Cog):
#A couple of simple command
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name="ping")
async def ping(self, ctx: commands.Context):
#Get the bot's current websocket latency.
await ctx.send(f"Pong! {round(self.bot.latency * 1000)}ms")
def setup(bot: commands.Bot):
bot.add_cog(SomeCommands(bot))
this command seem not be running when I try the command on my Discord server
Yeah
😭
ok im back
sorry i was gone for the day had to do family things
ok one i am really dumb plus i have not use python in years so imma need some one to lead me though this
im trying to get my bot to dm people with a certain roles
like dm everyone with that role
Get the role with Guild.get_role() (if you have ID, otherwise use discord.utils.get()) then get the list of members that have this role with Role.members then send a message to them by looping through the list and use Member.send()
how do i hide my discord bot token on repl?
You store it in a env. File
.env*
Oops
how can I make a form command to join the staff? Like: the person writes /apply and the bot sends the questionnaire... is it possible?
Use wait_for
So that you can wait for user response as normal message
User: /apply
Bot: What's your name?
User: xxxxx
Bot can do anything with thexxxxxresponse, such as saving or other things
i already tried this it, but, with many questions, i could not
You can with any number of questions
nvm
can i check if something errors? or would it return none? eg a string converted into an int
try/except
Although that's just generic python question, should check #❓|how-to-get-help
k ty
@client.command()
async def warn(ctx, member: discord.Member = None, *, reason=None):
if ctx.author idk :P``` How can I check if the person using the command has admin permissions?
@commands.has_permissions(administrator=True)
``` below the @client.command()
I can't use that in this instance, sadly. It needs to be an if check.
.guild_permissions.administrator
Returns a boolean whether or not the user has the permission
Thank you!
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
import discord
from discord.ext import commands
bot = commands.Bot(commands_prefix='o!')
@bot.command()
async def yur(ctx):
await ctx.reply('yesirrrr')
bot.run('Token')
like bro why it aint working
been like this for days
command_prefix, not commands_prefix
you telling me it was that simple😢
Yup
thank you
No problem
cursor.execute(f"SELECT channel_id FROM ticketdozamykania WHERE message_id = {x[0]}")
wynik4 = cursor.fetchall()
TicketChannel = self.client.get_channel(wynik4[0])
print("3")
await TicketChannel.delete()
await member.send("Usunoles ticketa")
TicketChannel has not attribute delete
When i send
channel.send()
to an channel with slowmode enabled the code freezes? is this normal behavior? it doesnt ever cause an error it just freezes.
for i in x:
channel = bot.get_channel(i)
await channel.send(advert)
await asyncio.sleep(3)
@normal folio ask for help
SyntaxError: 'await' outside function
If he removes await
Then there's another error
Yes we both commit dev
Because you can't execute async code outside of an async function
As simple as thay
await needs to be used within an async function
My brain committed die
my brain commited
100iq-100iq
await do_stuff() # not good
async def my_func():
await do_stuff() # good
ok
Ehat
You forgot an indent in your example
No
What
OH my discord was bugged had to refresh
Use the event for that
nah just after that explaining making this
cuz my brain didn't understand
Are cogs worth it?
I like organized but are they worth all the hassle
Ok imma go help u whatever
finally seeing onesaw working on bot suss??
Can someone help me with cogs or send a link or sum
if str(reaction.emoji) == "◀️":
Also i would recommend adding some check and timeout as that will wait forever and listen to ANY message the reactions are used on given the message is still cached if i remember correctly.
How would he do it?
a check?
The timeout
Ah i see ty
reaction, user = await self.bot.wait_for("reaction_add", check = yourcheckFunction, timeout= timeoutInSeconds)
Ok thanks
np
@client.command()
@commands.has_permissions(administrator=True)
async def whitelistadd(ctx, ):``` what's the best way of putting a Guild ID in the kwarg?
you want someone to input an id? you can just add guildId: int. and call that in your function.
there we go, didn't fully read at first, sorry.
Thank you so much! One last thing, how could I verify that the guildID is a valid ID if that's possible?
that i don't know. if you can hang on a sec i can try to find an answer for ya
Thank you, I really appreciate it!
I can't find anything i think would answer the question. The only thing i can think of is actually fetching the guild from discord's API with an API call (would return a partial guild i believe) and checking if anything was returned from discord. so essentially if a partialGuild object was returned you know its an actual guild snowflake otherwise it may not be? i haven't tested this so take it with a grain of salt, its just a best guess.
I see, thank you!
np, good luck.
is there a way i can set a link as an emoji in an embed?
uh no i don't believe so. Unless you are linking to an embed message that is already sent.
ok

