#discord-bots
1 messages ยท Page 76 of 1
DONE
ok
thx
how to repair it
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the messageโs hash.
you're using an unsupported type hint in a command parameter
help me out plz
stop spamming the same image, that's not the right channel
@bot.hybrid_command(name="gstop", with_app_command=True, description="")
@app_commands.guilds(discord.Object(id=770936389704613888))
async def gstop(ctx, mess: Optional[discord.Message]=None):
### stuff ###
using this
mess: Optional[discord.Message]
want channel is for that sort of problems
ok no [discord.Message]=None ?
#python-discussion or open an help channel
new slash command? that doesn't really make sense at all
no, you can't use discord.Message as type hint for param, it's not supported
you can use mess_id: int and then fetch or get the message with the id
what that mean ?
then what i should do ?
i can use this ?
what do you even gonna pass for a Message object conversion
true lmao
no
^
If you want a message object as a parameter for a command, a message context menu might be what you're looking for
oh i forgot that
@steep estuary
message context menu?
btw it's message commands
I think he/she means message commands
literally i am opening my bot script after months there are 100+ commands i don't know what to do
no
there's prefix commands, slash commands, message commands, user commands (and for dpy hybrid commands) idk if they're all called like this
lemme check
what's different between message and prefix commands
they're the same acm
Oh ! I forgot that i didn't update it on my main pc
Message commands are ones you can use from "Apps" section when you use message context menu
L
!d disnake.MessageCommand
class disnake.MessageCommand```
A message context menu command
!d disnake.UserCommand
class disnake.UserCommand```
A user context menu command.
!d discord.app_commands.context_menu perhaps it's called like this in dpy
@discord.app_commands.context_menu(*, name=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command context menu from a regular function.
This function must have a signature of [`Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") as its first parameter and taking either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member"), [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User"), or [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message"), or a [`typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.10)") of `Member` and `User` as its second parameter.
Examples...
isnt that user commands
They appear when you click on user
then what is different between user and message cmd
User commands are used on users and message commands are used on messages ๐ค
hurts my brain, I think I understood
sus
how do I add buttons to an embed?
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
you add buttons to the view, then you send the view with the embed
is there like a code snippet I can see
@paper sluice how do I get the persn who clicked on a button
anyone know how do I assign specific roles at player using a command? like !assign @person and the role will be fixed(using dpy)
How do i check what message a button is on
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
wot
async def assign(ctx, member: discord.Member):
await member.add_roles(role)```
Okay this
Print wel[0] and see what the outcome is
It is always on unless you close it
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
Changed in version 2.0: `channel_id` parameter is now positional-only.
It can return None as its a cache lookup
You would need to check what value youre passing or make a check to fetch the channel if Guild.get_channel returned None
doesnt fetchone return one random column
!d discord.Interaction.user
The user or member that sent the interaction.
Also... sorry but
How come only one button shows up?
@discord.ui.button(label = 'Left', style = discord.ButtonStyle.blurple, custom_id = 'Left')
async def Left(self, interaction: discord.Interaction, button: discord.ui.Button):
game = games.get(interaction.user.id, None)
if game is None:
return
else:
if game.instance.id == interaction.message.id:
game.move(directions.get('Left'))
@discord.ui.button(label = 'Down', style = discord.ButtonStyle.blurple, custom_id = 'Down')
async def Left(self, interaction: discord.Interaction, button: discord.ui.Button):
game = games.get(interaction.user.id, None)
if game is None:
return
else:
if game.instance.id == interaction.message.id:
game.move(directions.get('Down'))
@discord.ui.button(label = 'Up', style = discord.ButtonStyle.blurple, custom_id = 'Up')
async def Left(self, interaction: discord.Interaction, button: discord.ui.Button):
game = games.get(interaction.user.id, None)
if game is None:
return
else:
if game.instance.id == interaction.message.id:
game.move(directions.get('Up'))
@discord.ui.button(label = 'Right', style = discord.ButtonStyle.blurple, custom_id = 'Right')
async def Left(self, interaction: discord.Interaction, button: discord.ui.Button):
game = games.get(interaction.user.id, None)
if game is None:
return
else:
if game.instance.id == interaction.message.id:
game.move(directions.get('Right'))
there is no error
you named all your functions Left, so python only considers the last one
they are
you ofc
I named them all left?
change their names
OH IM SO DUMB, THANK YOU
thanks zaddy ๐
bruh, i forgot discord always puts the first text to the far left in a codeblock for no reason
yea
also i forgot to put this in
class Button(discord.ui.View):
def __init__(self) -> None:
super().__init__(timeout=None)
why does it not keep the state in a codeblock tho
okay im gonna go but thanks yall
no, its just that when you copy code, you start copying from the text, instead of the starting of the line
class Button(ui.View) ok
no im pretty sure discord also deletes any space char
if you try to send the message would be
>>> w
w
not in code blocks
def foo(self): ...
def bar(self): ...
what
do I have to pass it like
(role id or (<@&id>)?
discord is confusing me to a point its insane
the role object(s)
first time?
You should try to check its gateway and endpoints docs
when you copy text like this, thats when that problem happens
we should?
no, its a pain๐ญ
understandable, have a good day sir
anyways i think i need to drink my daily coffee my mind isnt currently working correctly
@paper sluice now i know why i was confusing myself
Mobile client:
Desktop client:
I had full on stroke because of it kek
why is self highlighted as keyword xD
because the syntax highlighting in mobile isnt consistent at all
anyways sorry for the confusion i will now go install revolt
all good xD
๐ฅฒ
property guild```
The guild the interaction was sent from.
lowercase g, you should also have a check to fetch the channel if needed
its a coroutine and you should have a check to avoid unnecessary calls
e.g
channel = interaction.guild.get_channel(int(wel[0])) or await interaction.guild.fetch_channel(int(wel[0]))
Hey!
Could someone help me make a rock paper scissors command!
Im using slash commands
im using py-cord (git+https://github.com/Pycord-Development/pycord)
Yes, but you should use my check ;33
wel = ...
...
come = ...
๐ณ
the channel isnt in the guild
looks like msg id
edit: ok channel id's digits got increased now
yeah theyre not the same
youre indexing the guild id
the index position must be 1
you used fetchone which returns the tuple of the column, which you saved the column as
and since youre fetching the channel its position in the tuple is 1
in ch change it to 1 and not 0
in the index ofc
the latter
mhm?
in fetch the channel, if you didnt understood
Yep :33
thats odd, can you print wel's value
yep!
wel
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
where's wel
have you printed it?
are you fetching a channel?
send the output
send your current code
Hey!
Could someone help me make a rock paper scissors command!
Im using slash commands
im using py-cord (git+https://github.com/Pycord-Development/pycord)
I made a seperate file to run my bots for me, It send this error
print wel before fetching the channel
have you installed PIL with pip?
Client.login is a coroutine, it need to be awaited
tell me how to install
!pypi PIL
pip install Pillow
C:\Users\jakub\Desktop\casino-bot-main>pip install Pillow
Requirement already satisfied: Pillow in c:\users\jakub\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (9.2.0)
pil is dead btw
can u help me out
what's the problem? we can't just write the code for you, so you either ask about a specific problem, like an error or don't ask at all
.
PIL is not installed
i cant install it
wdym
how man plz tell me
pip install PIL
C:\Users\jakub\Desktop\casino-bot-main>pip install Pillow
Requirement already satisfied: Pillow in c:\users\jakub\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (9.2.0)
that is Pillow ig
its whatever i figured out the error on my own
C:\Users\jakub\Desktop\casino-bot-main>pip install PIL
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
C:\Users\jakub\Desktop\casino-bot-main>
oh hm i guess it's actually pip install Pillow
hey im having a problem with the second slash command by the name of 'test' not showing up when i do / on discord, there is no error message and except for the command not showing the bot works great can someone help
import json
import discord
from discord.ext import commands
from discord import app_commands
from discord.ext.commands import Bot
from PIL import Image, ImageDraw, ImageFont
# Get configuration.json
with open("src\configuration.json", "r") as config:
data = json.load(config)
token = data["token"]
prefix = data["prefix"]
#get intents
intents = discord.Intents.default()
intents.message_content = True
intents.typing = False
intents.presences = False
intents.members = True
bot = commands.Bot(prefix, intents = intents)
@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name =f"{bot.command_prefix}help"))
print(discord.__version__)
@bot.tree.command(name="ping", description="...",)
async def _ping(interaction: discord.Interaction) -> None:
await interaction.response.send_message("pong")
@commands.hybrid_command(name="test", with_app_command=True, description="...2", guild_ids=['965888756722843679'])
async def test(self, ctx, user: discord.Member, role: discord.Role):
...
bot.run(token)
it uses a PIL namespace
C:\Users\jakub\Desktop\casino-bot-main>pip install pillow
Requirement already satisfied: pillow in c:\users\jakub\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (9.2.0)
weird
oh yeah could be
what can i do now
are your python's paths added to the PATH of your os?
idk im new in it
im not sure, but this code looks very sus for me
idk im new in it\
what do you mean?
hybrid command and app commands together (well that shouldnt be a problem)
not syncing a tree
idk idk
when you've installed python have you selected "Add python to the PATH system"?
who remembers that
idk but maybe i dont do it
๐
any sugestions
yes, check the system path
how man
.
If the PATH, ORACLE_SID, and ORACLE_HOME environment variables do not exist, you must create them.
ignore the oracle instructions to add their path
btw you can see the paths in the same way
what now
check if there's python
@commands.command()
async def cast(self, ctx, *, message):
users = ctx.guild.members
result = []
role = discord.utils.get(ctx.guild.roles, id=1003083781969817650)
role2 = discord.utils.get(ctx.guild.roles, id=796467484768075786)
for user in users:
if role in user.roles:
result.append(user)
elif role2 in user.roles:
result.append(user)
for user in result:
await user.send(message)
await ctx.send("Your message has been broadcasted")```If someone blocks the bot does it break it?
Forbidden: 403 Forbidden (error code: 50007Is the error
Why does this come up if there are no errors
async def move(self, direction: tuple) -> None:
self.head = (self.head[0] + direction[0], self.head[1] + direction[1])
self.body.insert(0, self.previous_head)
self.body.pop()
await self.instance.edit(embed=discord.Embed(
title = f'{self.ctx.author.name}\'s Snake Game',
colour = 0x56e786,
description = self.generateBoard(),
))
Yeah but you can just use a try except
alright thanks
Are await interaction.response.defer() In the button callback
no
What does that do
try:
await ctx.send("Your message has been broadcasted")
except:
print("Works")```Like this?
ok
You should make that except discord.Forbidden:
Well do you wanna skip the user if they have the bot blocked or dms off?
yeah skip
The just put pass
ok
Also the try except should be around user.send
@commands.command()
async def volume(self,ctx:commands.Context,volume:int):
if not ctx.voice_client:
await ctx.send('I\'m not in a voice channel... so how will I change my volume?')
return
elif not getattr(ctx.author.voice,'channel',None):
await ctx.send('Join a voice channel first lol.')
return
else:
vc:wavelink.Player=ctx.voice_client
if volume > 100:
await ctx.send('That is too high.')
return
elif volume < 0:
await ctx.send('That is too low.')
return
await ctx.send(f'Set the volume to {volume}.')
await vc.set_volume(volume)
return
whenever i change the volume of a video, the bot just stops playing the video completely. i dont think the volume changes either. does anyone know how to fix this?
that's something to ask in the wavelink discord server I guess
o alright
also, if you're returning in an if statement, you don't need the elif
if shit:
# ...
return
elif other_shit:
#...```
i see
is basically
if shit:
# ...
return
if other_shit:
# ...```
thank you
not exactly without return, you should state how elif differentiates vs another if statement
Quick question, for a discord bot that has a snake game, would the player want the snake to be constantly moving and the player picks the direction, or does it move one block at a time if they press one button? cuz its a discord bot
true, you could still see the connection
snake games can cause ratelimits, since you're constantly editing the message
So what should I do?
let's say 100 members play that game at once, can you imagine?
you make another game
wait like
100 people play one snake game or 100 people play 100 different snake games @potent spear
the latter
"once" isnt the best word to choose, concurrently fits better
๐ฆ
yeah, "at the same time"
How about I set a limit on how many snake games can be played in the server
max_concurrency is a decorator which you can put on top of a command
What does it do
the docs will tell you
Okay wait... just saying. I have this:
@Arcade.tree.command()
async def snake(interaction: discord.Interaction) -> None:
"""Arcade game: Snake"""
ctx = await commands.Context.from_interaction(interaction)
game = games.get(interaction.user.id, None)
if game is None:
games[interaction.user.id] = message = Snake(ctx)
await games[interaction.user.id].construct()
else:
await interaction.response.send_message(f'Close the instance of your previous game {interaction.user.mention}', ephemeral = True)
so I add that to the top of @arcade.tree.command()?
I handle each game in a class.
making a snake game can be quite hard, since the smallest lag can cause a player to simply lose
have you seen any bot with a snake game?
Well it moves one tile at a time. It's not really a constant moving snake.
it's like a turn type game, I want to do constant but, I know discord isn't made for that.
It's just that
https://youtu.be/UqQz1qkBMkE?t=148 just watch 5 secs of that
Okay, I get it, 5 api requests every 5 seconds
But where would I put it Sniper @potent spear Because I have buttons that call a move function
put what?
the decorator
I have 3 functions,
One is for the button that triggers it to move
The other is to create the game
The third actually moves it
Or maybe im understanding it wrong
Well, obviously you want to prevent members from creating games
you still have to add a per kwarg
try and see
try and see, that's all I can say
Okay besides that... im so confused
When I move my snake to the side of the screen, and then press right, it goes to the other side of the screen
like pacman
Why?
well obviously you dont know the code, I dont wanna ruin your day actually
maybe ill open a help channel
well, just debug. Think about it
what you obviously do is first make a snakegame in the terminal / console and then move it to a dpy project...
I've made one before, I just used a different method this time but now
instantly implementating it in dpy is mostly a bad idea
How to check if someone pinged someone with a reply?
Like this
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
Hey! When i use datetime.datetime.now()
I get this error Application Command raised an exception: AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
Can someone help me please
did you imported datetime only? show imports
i got it
for sum reason it doesnt like datetime.datetime
i just used datetime.now() and now it works
i suppose you did
from datetime import datetime
do remember that the second datetime is a class
it just doesnt have ClassNaming
ah
congrats!
thx
Can someone give me advice.
SHOULD I MAKE MY SNAKE BOT move like google snake, where you pick the direction but it moves constantly
or should i make it so if you press a button in moves in that direction one tile
My problem is that someone told me that it can cause so much lag if its constant
If you make it move constantly you'll have a chance to get rate limited
So I have a slash command which takes a attachment input and sends it in a embed but I also want this command to send a modal.
This modal will create a embed with all of the values from the modal and I also want it to add the attachment to the embed.
Is there a way for me to pass the attachment through to the model to access in the on_submit or should I use return statements in the on_submit and on_error funcs of the model and construct the embed in the command func?
Some ppl over on dpy suggested using the init to pass the attachment object in, Whilst I have used init and super init a few times now they still confuse me when writing them to start with. This is my current command```py
class CustomInstanceRequest(Modal, title="Custom Instance Request"):
def init(self, attachment, channel, custom_id: str = "CustomInstanceRequest") -> None:
self.attachment = attachment
self.channel = channel
name = TextInput(label="Bot Name", placeholder="Your bot name here...\nDefault: ModMail\n(optional)", min_length=1, max_length=32, default="ModMail", required=False,)
activity = TextInput(label="Bot status activity", placeholder="Your bot status here...\nDefault: DM to Contact Staff | =help\n(optional)", max_length=128, default="DM to Contact Staff | =help", required=False,)
about_me = TextInput(label="Bot About Me", placeholder="Your bot about me here...\n(optional)", max_length=400, required=False,)
server = TextInput(label="Bot Server", placeholder="Your bot server here...\n(required)",)
customizations = TextInput(label="What other customizations would you like? If any", style=TextStyle.long, placeholder="Type your requests here...", required=False, max_length=300,)
async def on_submit(self, interaction: Interaction):
embed = CustomEmbed(title="Custom Instance Application")
embed.add_field(name="User", value=f"{interaction.user.mention} ({interaction.user.id})",)
embed.add_field(name="Attachment", value=f"{self.attachment.filename} ({self.attachment.size} bytes)",)
embed.set_footer(text="Sent via FAQ")
await self.channel.send(embed=embed)
await interaction.response.send_message(f"Thanks for your instance request, {interaction.user.display_name}!", ephemeral=True,)
async def on_error(self, interaction: Interaction, error: Exception) -> None:
await interaction.response.send_message("Oops! Something went wrong.", ephemeral=True)
log.error(f"{error.__class__.__name__}: {error}")
@client.tree.command(name="custom", description="Apply for a custom instance of ModMail",)
@app_commands.describe(attachment="The profile picture you want for your bot")
async def custom_instance_application(interaction: Interaction, attachment: Attachment = None):
channel = client.get_channel(int(client.config.INSTANCE_REQUESTS))
await interaction.response.send_modal(CustomInstanceRequest(attachment=attachment, channel=channel))
# await interaction.followup("Your application has been submitted, you will be contacted shortly.", ephemeral=True,)```but whenever I run it I get a command not found error. I tried doing a manual client.tree.add_command() but it says the commands already registered (and it is appearing on Discord). I am still on a dev branch and need to migrate to the stable pypi branch of Dpy 2.0 however my pip seems to be broken so I'm going to reinstall python at some point soon to hopefully fix it
So basically snake is a nono when it comes to discord?
Not exactly, you can still make it
What if its for a big server
so i have 100 snake games running concurrently, lets say
that would definitely be a... what do you call it, it'd be limited irght?
One game per channel, once the game ends the command can be ran again
Oh
Okay, doesn't sound too bad.
So one game per channel
Hmm
i like that, i love it
๐
hm
Let me try it.
actually too complicated ๐
I am a noobie
This is prototype 2.0, maybe 3.0 will do that
on a scale of 1 to 10 how bad is it to name a class get
0
As in very very bad
Here's a tip, when someone starts the game (assuming you have your command in a cog which is essentially just a class), you can add some bool attribute and at the start of the command check for it, you could name it something like is_running or anything really, then have it False by default, when someone starts you change it to True, when you check for it if it's True then you return a message so no one else can run it again until the first person is done, and at the end of the code when they're done you basically just change it back to False
Unless you're using prefixed commands which is much easier since there's the @fresh banemands.max_concurrency decorator
Definitely this otherwise it'll get ratelimited by the api
I feel like there's something missing in your modal, I don't see the "name" and everything else being added to the modal, instead you're just making them variables within the init which you can only access within the init
Same
Then again I don't even use dpy I use disnake so you might wanna look into some examples of dpy modals or even the documentation itself
I honestly believe thatโs how you're supposed to do it. Itโs done that way as well in the example for modals in the repo.
Thanks man ๐๐๐๐๐
Weird but aight
Np
Who knows man
Maybe it's the init? Don't see any super init in there
While in the example there's no init in the first place
Okay i dont feel like this is ticket worthy , im j starting to dev a bot , how would i pass down an argument from the command into like say an if statment something like this
k = 'lol'
@bot.command()
async def redeem(ctx, key):
if k = key:
print("worked")
else:
print("didnt work / key isnt not right")
just like that, but use == for comparisons isntead of =, which is used for assignment
lol looking over this i did a terrible job on it
Okay okay thanks i was just wondering if i was doing it right
could somoene help me please? i cant find this file and im trying to delete it so my music code can work again
First, what code editor do you use, second, its ur cogs.music.py
@austere vale third of all, its saying from discord import Enum is invalid
check for a line like that.
4th of all I would really like to know what editor you use because that seems so sick.
looks like replit
im using replit since i currently dont have a pc i can host the bot on yet, and theres nothing like that in the music file. someone told me to run https://github.com/PythonistaGuild/Wavelink.git, but it wasnt working out so now im trying to retrace my steps and delete it
damn it
but is this a good purge comm for dpy?
Im running this command
scraper = cloudscraper.create_scraper()
@bot.command()
async def crash(ctx):
games = scraper.get("https://rest-bf.blox.land/games/crash").json()
def lol():
r=scraper.get("https://rest-bf.blox.land/games/crash").json()["history"]
yield [r[0]["crashPoint"], [float(crashpoint["crashPoint"]) for crashpoint in r[-2:]]]
for game in lol():
games = game[1]
lastgame = game[0]
avg = sum(games)/len(games)
chance = 1
for game in games:
chance = chance = 95/game
prediction = (1/(1-(chance))+avg)/2
And im getting this error below , cant figure out whats wrong ?
Traceback (most recent call last):
File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\jonat\Desktop\MAIN DIR DEMON PREDITCOR\main.py", line 42, in crash
games = scraper.get("https://rest-bf.blox.land/games/crash").json()["history"]
File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 976, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Obvly isnt the full code , but i think this enough j for the error
.json() returned nothing
bad bot
how do i get the guild id of a server my bot is in?
Which server? The first one?
how do i fix this error?
@commands.command()
async def splay(self, ctx:commands.Context,*,search:str):
if not ctx.voice_client:
vc:wavelink.Player=await ctx.author.voice.channel.connect(cls= wavelink.Player)
elif not ctx.author.voice:
await ctx.send('Join a voice channel first lol.')
return
elif not ctx.author.voice.channel==ctx.voice_client.channel:
await ctx.send('We need to be in the same voice channel.')
return
else:
vc:wavelink.Player=ctx.voice_client
if vc.queue.is_empty and not vc.is_playing():
try:
track=await spotify.SpotifyTrack.search(query=search, return_first=True)
await vc.play(track)
await ctx.send(f'Now playing: {track.title}! {track.uri}')
except Exception as e:
await ctx.send('Please enter a Spotify url.')
print(e)
return
else:
await vc.queue.put_wait(search)
await ctx.send(f'Added {search.title} to the queue! {search.uri}')
vc.ctx=ctx
if vc.loop:
return
setattr(vc,'loop',False)
kill 1
ye i tried that but it just turned itself back on and kept spamming
rip
Just the ID of the server, it can be any
So you want to pick a random server your bot is in, and get it's ID?
Okay because of this robin,
basically for each server, for the new snake game bot, I am setting it's limit to one snake game per server
and i have a dictionary so
idk something like that
wait lemme figure it out.
I'm sorry for not making sense.
I'd probably go with a structure similar to
snake_games: Dict[str, bool] = {
"server_id_1": True,
"server_id_2": False,
"server_id_3": True,
}
This would specify which servers have and have not a snake game running
yea okay.
Thank you ๐
Okay this is the thing.
A user says /snake, right?
I need to know what server the user is in so I know if a game is running or not.
You have another 'enum' module installed, uninstall it
u want the server Id?
How would i make my bot ignore users thats above the bot in the tole hierarchy
!d discord.Interaction.guild
property guild```
The guild the interaction was sent from.
what should i look into to Unfuglify this help menu? https://imgur.com/8JOe6sq
im looking to use a def func to return a default value that i can parse into a bot command. im not sure how to actually get the return value into the second func tho
ie
def fruit():
apple = 'fruit1'
return apple
@bot.command(name=...)
def salad(apple):
if apple == 'fruit1':
...
i cant figure how to actually parse apple into the second func
if user.top_role > ctx.guild.me.top_role: ignore
wdym Unfuglify
!custom-help make ur own
Custom help commands in discord.py
To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000
if i.user.top_role >= bot.top_role
return
Check this channels pins, there should be a message about ANSI code blocks (basically just custom colored text with styles like bold, italics, ..etc)
ansi code blocks won't work for mobile users
you should have the bot as member instance
@silk fulcrum would self.bot.top_role work since its in a listener
Well yea, I mean code blocks donโt even work for me on mobile anyways
But having them is a nice touch, you can always encapsulate with an embed
no, self.bot is commands.Bot instance, not Member
you need guild.me
if you need the bot's top role in a server you should be using Guild.me.top_role
what does that mean
channel.guild.me*
alright
and i think you'd better use pass instead of return
cus return will stop the whole event
and you won't be able to check other users
thats the point
ok
Wait what u mean stop the whole event
It's saying wel is a 1-tuple
and you're trying to access the second element
you cannot access the second element of a tuple that has only 1 item
if you want the first item, sure
then the channel ID you're storing is wrong 
or the channel belongs to another guild
how can i delete the message the user sent?
Use ctx.message.delete()? 
๐ thanks didnt know
why don't you just condense those two select queries into one
SELECT msg, channelID
yeah, now you can get both the values in 1 query instead of 2
you remove the first query entirely
then when you fetch from the cursor for the new query, it'll return a tuple of (msg, channelID)
yes but now you need 2nd item, not first
yes
are you sure the channel id is correct and it's in the same server as where you're calling the command from?
hey im having a problem with the second slash command by the name of 'test' not showing up when i do / on discord, there is no error message and except for the command not showing the bot works great can someone help
import json
import discord
from discord.ext import commands
from discord import app_commands
from discord.ext.commands import Bot
from PIL import Image, ImageDraw, ImageFont
# Get configuration.json
with open("src\configuration.json", "r") as config:
data = json.load(config)
token = data["token"]
prefix = data["prefix"]
#get intents
intents = discord.Intents.default()
intents.message_content = True
intents.typing = False
intents.presences = False
intents.members = True
bot = commands.Bot(prefix, intents = intents)
@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name =f"{bot.command_prefix}help"))
print(discord.__version__)
@bot.tree.command(name="ping", description="...",)
async def _ping(interaction: discord.Interaction) -> None:
await interaction.response.send_message("pong")
@commands.hybrid_command(name="test", with_app_command=True, description="...2", guild_ids=['965888756722843679'])
async def test(self, ctx, user: discord.Member, role: discord.Role):
...
bot.run(token)
@discord.ext.commands.hybrid_command(name=..., *, with_app_command=True, **attrs)```
A decorator that transforms a function into a [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand").
A hybrid command is one that functions both as a regular [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and one that is also a [`app_commands.Command`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command").
The callback being attached to the command must be representable as an application command callback. Converters are silently converted into a [`Transformer`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Transformer "discord.app_commands.Transformer") with a [`discord.AppCommandOptionType.string`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.AppCommandOptionType.string "discord.AppCommandOptionType.string") type.
Checks and error handlers are dispatched and called as-if they were commands similar to [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command"). This means that they take [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") as a parameter rather than [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction").
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
New in version 2.0.
and with_app_command is True by default
I think you should use bot.hybrid_command here
https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.hybrid_command
is it possible to use ctx in a loop?
sure, but you'll need to pass ctx to it when you start it
and how do i do that? Im in a cog btw
just as you would pass an argument to any function
So if I understand replaceโโโcommands.hybrid_commandโโโ with bot.hybrid_command ?
Yup
K Iโll try that later thanks
Also is this because commands now need to be registered?
is the channel in the server you're doing the command from
well
that's an issue with your code's logic, you'll need to figure out what's happening there
what's your db schema
what's your db structure
their types too
which is the important part
you can use DESCRIBE Table
and what's the primary key
oh boy
how are you preventing data redundancy
what if a guild has 2 channels set, which do you use
how do you know which is the "correct" one
then you should have the guild id as PK
yes
primary key implies not null anyways
like you don't need to add that constraint manually
It's saying you have a duplicate guild id
Honestly i would just drop the table and recreate it
GUILD ID should be pk
Primary Key
Latter by sql convention
you didn't specify the datatype for guildID
CREATE TABLE Welcome (
guild_id BIGINT PRIMARY KEY,
channel_id BIGINT,
msg TEXT
);
May I ask why people are using create table inside their python code?
To make SQL table
What database needs that?
Since almost every SQL type I know can you make predefined tables.
๐ซก
maybe they create it if the table doesn't exist
who knows, maybe it's open source
but a better option would be an init.sql
A better option would be create a class that represents the database cuz i keep seeing that code and everytime my eyes hurts even more
did i do anything wrong
I can't see the whole error messages
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
Fixed it
Host it urself
bruh wdym by that
Writing a new confession deletes the old one... How can i fix that?
Use a mode
Instead of w
thanks
Get a rootserver or something and host it urself
best option
too broke
but it costs mine is small i pay like 4$ a month
damn
that's big amount of bobuk
massive..
:(
sry
you could try heroku
itโs kinda like replit but you only have 20 days/month or smth
which?
They've removed the free tier
oh sad :(
Linux Root
isn't it kind of weird to be spying on your users' confessions?
sounds creepy
frfr
not yet from November
def sendMessage(token, channel_id, message):
url = 'https://discord.com/api/v8/channels/{}/messages'.format(channel_id)
data = {"content": message}
header = {"authorization": token}
r = requests.post(url, data=data, headers=header)
print(r.status_code)
Guys i made this func to send message
But i getting 401 status
How can I fix it?
Why r u manually sending requests tho
:?
Authorization case matters
Also it is Bot token.goes.here
So you gotta use it like
headers = {"Authorization": f"Bot {token}"}```
Like this?
"Authorization": f"Bot {token}"
are you using discord.py?
Yes
I meant, use discord.py
Don't send requests manually
I'll use it in my website
How do I fix an SSL error? I get it when I'm starting my bot
whats the error, send traceback
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.
https://stackoverflow.com/a/58525755/17268995
try this out
user-MacBook-Air:~ user$ /Applications/Python\ 3.9/Install\ Certificates.command ; exit;
-- pip install --upgrade certifi
Collecting certifi
Using cached certifi-2022.6.15-py3-none-any.whl (160 kB)
Installing collected packages: certifi
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/certifi'
Consider using the `--user` option or check the permissions.
WARNING: You are using pip version 21.1.1; however, version 22.2.2 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install --upgrade pip' command.
Traceback (most recent call last):
File "<stdin>", line 44, in <module>
File "<stdin>", line 24, in main
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9', '-E', '-s', '-m', 'pip', 'install', '--upgrade', 'certifi']' returned non-zero exit status 1.
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
So I should use 3.8?
i dont think you should, try asking in #unix , folks there might help you
That caused the error
You could host it directly on your own machine too, but if you do then that would require leaving it on, or you could buy a rasberry pi which in the longer term will save you spending on hosting service for one short term purchase.
AWS also provide a free tier, but you would require a bank account to sign up. https://aws.amazon.com/free/ before just signing up, make sure to read what is available for free as I have seen more than my fair share of people rack up bills in the 1000s and even look at setting up billing alerts to make sure you don't get services that will cost.
in replit it crashes cause of 429 error and rn I can't afford any, I don't have a credit card, I mean I kinda lost mine when I was a kid
so I need to host bot for free with no crash
realistically, you're not going to be able to do that
there's also oracle cloud that allows a user to host for free an application (24gb ram 4 cores) but you need a credit card
You can reissue the card can't you
Also they steal your data ๐
"realistically", i think the person ment you cant use any resources without giving anything the supplier can use e.g most hosts always have a free tier/trial or a free month after a purchase and needs credentials to confirm the order
ik
who's your provider 
guys, how do I get the name of the vc a member is in?
!d discord.Member.voice
property voice```
Returns the memberโs current voice state.
This returns VoiceState which has a channel attr
It's a german host
mc-host24
ahhh, interesting
thank you :D
yw
no idea, try it and see
you should use a webhook instead then
xcuseme
How do I detect if someone mentioned a specific user? Iโm using on_message but surely thereโs a better way? And also it doesnโt detect reply mentions
.mentions returns both replies and mentions iirc
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
oh this is convenient attr
hi can anyone help me write python script
i need to create script that would add "credits" to people with command
have you setted a command_prefix with a char?
have you enabled message_content intent on the discord developer website?
yep
i fixed it
async def add(ctx, member: discord.Member, *, reason) -> None:
this will work?
why it shouldn't
hi is there someone who can help me write a discord bot command in python
yes?
i got an gambling discord bot
and i want to create a command witch add people coins
like $add @analog aurora 1000
you have to use a database as excpected
which one ?
sqlite3
you can use 'tinydb' it's easier
.
i got some commands from my friend and i want create a new one but im so bad at it
Is it poss, to make this into a embed?
Make what ?
The add command into a embed, How pls.
I just pasted it into double ```
mines a + command, but it wonโt send in a embed ๐
Like this ?
idk why my bot cant boot right now
its just show and instantly gone
im big beginner in this shi sorry for me
is it good?
is doing the same
cant boot
yea
Traceback (most recent call last):
File "c:\Users\jakub\Desktop\casino-bot-main\discord\bot.py", line 19, in <module>
client.load_extension(f'cogs.{filename[:-3]}')
File "C:\Users\jakub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\jakub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.blackjack' raised an error: ModuleNotFoundError: No module named 'PIL'
PS C:\Users\jakub\Desktop\casino-bot-main\discord>
Write in cmd:
pip install pillow
i got it
C:\Users\jakub>pip install pillow
Requirement already satisfied: pillow in c:\users\jakub\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (9.2.0)
C:\Users\jakub>
C:\Users\jakub>pip install Pillow
Requirement already satisfied: Pillow in c:\users\jakub\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (9.2.0)
C:\Users\jakub>
i got it installed yesterday
C:\Users\jakub>python --version
Python 3.10.6
C:\Users\jakub>pip --version
pip 22.2.2 from C:\Users\jakub\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip (python 3.10)
C:\Users\jakub>
i use bot on python 3.7.0
how to
!dashmpip
When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.
Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.
Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.
Py 3.7 -m pip install pillow
3.7
C:\Users\jakub>Py 3.7 -m pip install pillow
C:\Users\jakub\AppData\Local\Programs\Python\Python310\python.exe: can't open file 'C:\Users\jakub\3.7': [Errno 2] No such file or directory
C:\Users\jakub>
Py3.7
This is why venvs exist
C:\Users\jakub>python3.7
'python3.7' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\jakub>
C:\Users\jakub>Py3.7 -m pip install pillow
'Py3.7' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\jakub>
C:\Users\jakub>py --version
Python 3.10.5
C:\Users\jakub>
@analog aurora how do you launch a bot?
Anyone know what this error means?
TypeError: TypedDict does not support instance and class checks
how do you use TypedDict?
im not sure, i get the error after interacting with a button..
could you show me the code?
what is that thing called where i can copy and paste code that is too big to be sent here?
cant just?
11
double click on that path thats highlighted blue
then make it longer and send ss
ofc blocking out whatever you need
just seeing that above ss its not added
C:\Users\jakub\AppData\Local\Programs\Python\{your python version which if i saw was 3.7?}\Scripts
new >
C:\Users\jakub\AppData\Local\Programs\Python\Python37\Scripts
just adding it to path
and just python?
do python with no arg
it got me microsoft store
x)
just do pip list > req.txt
i mean idk what i have
if you are going to go to the extent of reinstalling you may as well switch to a venv
it will save all libraries in a .txt which you can use it install
PS C:\Users\jakub> pip list > req.txt
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- pip list > req.txt
-
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\jakub>
C:\Users\jakub>pip list > req.txt
'pip' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\jakub>
doesnt have it on path either way ;p
breh
i got work lads i wish ya luck
bye
@analog aurora install python from python.org and run the executable as admin
the bot has access to that channel?
in your await cursor.execute(INSERT INTO welcome..., what is ON DUPLICATE KEY MSG.. for?
Just been following this but been working, did you install python from the MS store from what I gather? Or from a direct download from the site?
3.7 from web
from python.org
You should of had the option from the installer to add the PATH variable, did you not check it?
i click it when installer wasx
so, you're wanting to update your database when a new person joins?
it cant boot even now
OK, let me get a better understanding of what your trying to achieve on your Windows box before we go any further
Downloading https://files.pythonhosted.org/packages/95/01/e41b5817ec6358562db806f532862f0a95ba349735df5b78c4f423e368f9/yarl-1.6.3-cp37-cp37m-win32.whl (119kB)
100% |โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 122kB 4.1MB/s
Installing collected packages: typing-extensions, async-timeout, multidict, idna, yarl, chardet, attrs, aiohttp, discord.py, Pillow, PyYAML
The script chardetect.exe is installed in 'c:\users\jakub\appdata\local\programs\python\python37-32\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed Pillow-8.2.0 PyYAML-5.4.1 aiohttp-3.7.4.post0 async-timeout-3.0.1 attrs-20.3.0 chardet-4.0.0 discord.py-1.7.1 idna-3.1 multidict-5.1.0 typing-extensions-3.7.4.3 yarl-1.6.3
You are using pip version 10.0.1, however version 22.2.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\jakub\Desktop\casino-bot-main>
OK, this means nothing to me all I see is you installed something successfully, what are you trying to achieve?
https://www.python.org/downloads/
download from this
most discord wrappers require python 3.8 or above
Where is the indent error ?
async def add(ctx,member : discord.member, reason) -> None :
try :
lista = (db.search(users.id == member.id))[0]
await ctx.send ("**"+member.name+" is already in the scammers list.**")
except :
db.insert({'id':member.id, 'isScammer':True,'reason':reason})
ScammersRole = ctx.guild.get_role(1012422162981855282)
await member.add_roles(ScammersRole)
bot.run("token")```
i usually do this, cursor.execute(f"INSERT INTO welcome (guildID) VALUES ('{guild.id}')"), maybe you can find a way to do it like this too?
yes
can you send the traceback?
blocking db functions
and nice arguments
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/converter.py", line 1214, in _actual_conversion
return converter(argument)
TypeError: 'module' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 978, in invoke
await self.prepare(ctx)
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 895, in prepare
await self._parse_arguments(ctx)
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 802, in _parse_arguments
transformed = await self.transform(ctx, param, attachments)
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 672, in transform
return await run_converters(ctx, converter, argument, param) # type: ignore
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/converter.py", line 1323, in run_converters
return await _actual_conversion(ctx, converter, argument, param)
File "/home/runner/kk/venv/lib/python3.8/site-packages/discord/ext/commands/converter.py", line 1223, in _actual_conversion
raise BadArgument(f'Converting to "{name}" failed for parameter "{param.name}".') from exc
discord.ext.commands.errors.BadArgument: Converting to "discord.member" failed for parameter "member".
help
its discord.Member not member
ok
anyone know what this error means?
TypeError: TypedDict does not support instance and class checks
discord.ext.commands.errors.MissingRequiredArgument: reason is a required argument that is missing.
but in my code , i have :
async def add(ctx,member : discord.Member, reason) -> None :
Hey!
i have a bot command that when you type /ticket it makes a text channel
But it doesnt change the topic of the channel
How would i do that?
it will be always marked as none !
should also use annotations
how can i make a discord bot check someone's role on a server
like if i use a command in the bot's dms instead of a server
how do i make the bot check for a whitelisted role in that exact server
The value would always be None if the argument with the value isnt supplied upon each call of the function
class Butto(nextcord.ui.View):
def __init__(self, ctx):
super().__init__()
self.ctx = ctx
async def interaction_check(self, interaction):
return self.ctx.author == interaction.user
@nextcord.ui.button(
label = "Send",
custom_id="send",
style=nextcord.ButtonStyle.green,
row=1
)
async def send(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
embed = nextcord.Embed(
description="eeeee"
)
await interaction.response.send_message(embed=embed)
class Tester(commands.Cog):
def __init__(self, bot):
self.bot = bot
@nextcord.slash_command(description="๐ Create an embed in the cureent channel.")
async def create(self, interaction: nextcord.Interaction):
view = Butto(ctx =)
embed = nextcord.Embed(
description="jhdhjehked"
)
await interaction.response.send_message(embed=embed, view=view)
def setup(bot):
bot.add_cog(Tester(bot))
dont rlly know what to put in the ctx = part to make the interaction check to work
can yall help pls
ah
Well that should work
!d discord.Guild.owner
property owner```
The member that owns the guild.
so user2 = discord.Guild.owner.id ok
guild = ctx.guild
user2 = guild.owner_id
i think
thats how my server info command is done
ok
or you can do
user2 = ctx.guild.owner_id
OK!!
do anyone know how is this thing called?
<t:1171717171>
timestamps
tysm
You can use the following code to check if a user has a specific role on a Discord server:
if user in server.roles:
print("User has the role!")
else:
print("User does not have the role.")
why is bro named server
and role named user
it's if role_instance in member_instance.roles
AND HOW WOULD I USE THAT
caps
hm, is there a way to make a function run just like setup_hook?
like which is called once right before startup?
how do i use role_instance in member_instance.roles
i don't know what channel you want ๐ฟ
like that ๐ฟ
replace role_instance with Role instance and member_instance with Member instance
why do you have ids of the channels which don't exist in the first place?
what does that mean
๐ฟ you dont know what are instances?
no
well, if you know what the problem is, try to fix that instead of asking to avoid that error
ask yourself, why is the channel id same and then fix your code accordingly
then what do you understand?
nothing i only know lua
you are inserting self.channel.id, is self.channel changing or is it same throughout?
wtf, do you mean you dont know anything?
pretty much
are u russian or what?
cus russians build sentences with lots of negatives
like "I don't know nothing" (if translating word by word)
and also if you don't know what all these words mean then you should consider learning that
what
what did you change?
wdym "time string"
store a time as an epoch
@slate swan https://docs.python.org/3/tutorial/classes.html
learn about classes, they will help you a lot because most discord wrappers use OOP
sql databases can store DATE or TIME or even DATETIME iirc
well, first try to fix the original problem
or just use an ORM which does the datetime conversions for you
well, then figure it out. Analyze your code and see why channel id is same...
object relational mapping, in this context it basically means converting sql objects to python objects. There are libraries like sqlalchemy which do that
you wrote the code right?
then you should be aware of it
You should learn about the basics of python then when you get the hang of it start learning python's OOP and Asynchronous programing and its syntax in python, before working with a advanced lib that depends on the paradigm and so does the language
i just wanna make a bot
im not gonna learn a whole coding language ๐ฟ
its not the whole language, not even close
still
its just some basic concepts which you need to learn before making a discord bot.
idk
!d discord.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick "discord.Guild.kick").
Thank You!
ch can be a literal of NoneType as the method being used has a return type of a -> None |abc.GuildChannel | Thread | abc.PrivateChannel
but i want from a server
Then just use lua?
nothing i only know lua
?
you can make bots with lua?
Does it look like ive worked with Lua?
> text
oh
You make a check?
@paper sluice any idea?
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
1
if youre wondering what would be the second option it would be a method to fetch the channel by making an HTTP request to the discord REST API
!d discord.ext.commands.Bot.fetch_channel
await fetch_channel(channel_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Thread "discord.Thread") with the specified ID.
Note
This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.
New in version 1.2.
Changed in version 2.0: `channel_id` parameter is now positional-only.
about?
about kick some one from server not from any server
like
i do /kick Member:Hello
it not kick in this server
it kick from other server i select
it depends on which instance you use the method on?
get the guild object and kick from there
example ๐ฆ
!d discord.Guild.kick
await kick(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`kick_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.kick_members "discord.Permissions.kick_members") permission to do this.
idk
?
idk ๐ฆ
it depends on which instance you use the method on?
what this mean
you make a discord.Guild objecct of the the server you want to kick from, then you do .kick from there.
example ๐ฆ
more like have a method that creates and instance and returns it
how do I check if command message is replied to another msg
IDK
so that bot can reply to the same message I replied
howw???
like await kick(user, {{server}, reason=None)
or what
Guild.kick
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
Oh
is it like: py @bot.command() async def abc(ctx): msg = ctx.message.reference await msg.reply("asdf")
!d discord.MessageReference
class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)```
Represents a reference to a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message").
New in version 1.5.
Changed in version 1.6: This class can now be constructed by users.
ah?
?
i still not understand ๐ฆ
\๐
As shown in docs, MessageReference has no reply attribute, Message.reference can return discord.Message | None so its vulnerable to attribute errors
.kick on Guild object
where would server be defined and why make another pointer?
yes
so I can collect Message.reference's id first then I can make a reply?
OH, there's one .resolved
โ๏ธ
I'm confused
!d discord.Member.status
property status```
The memberโs overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
How do i use this inside an command?
You just get an instance of Member?
like this? a = await client.fetch_user(584748051814547487)
and then await ctx.send(str(a.status)) ?
nope
oh
the attribute returns a string?
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
Changed in version 2.0: `member_id` parameter is now positional-only.
if you want a certain member always
you can always use an argument or the author, it depends on what you want
so await fetch_member(id)
and then this
do you want always a certain user?
yes
no need to make it a string...
well then, yes and no, it would work but you should avoid making unnecessary HTTP requests by checking the cache of the bot for the member
the member must be the in the guild
i am
instance?
Returns the guild associated with this contextโs command. None if not available.
Can you please send the code for this?
I already have given you what you need?
Yes, but i dont get it
What do you not get?
everything lmao
Well do you know about python's OOP?
?
Ill take that as a no.
Well then, you should learn about the basics of python then when you get the hang of it start learning python's OOP and Asynchronous programing and its syntax in python, before working with a advanced lib that depends on the paradigm and so does the language
can you show your code?
Ok
message content intent? :hm:
ok
my bot works in dms but not on my server
uh oh
he should have the message content intent as the command is getting invoked in dms
1 sec i gotta replace some of the variable names theyre weird af
no?
who has time for that
?
ั = await forever_coro_with_yomama(123456)``` that's how you call vars @primal token
just ั
ok
or ััั
import time
import os
import discord
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
client = discord.Client(intents=discord.Intents.default())
dr = webdriver.Chrome(options=chrome_options)
dr.get("https://bloxflip.com/crash")
doc = BeautifulSoup(dr.page_source, "lxml")
pasts = doc.find_all(text="Log in")
print(pasts)
time.sleep(5)
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('.predict'):
crack = 1
coolsex = 2
doc = BeautifulSoup(dr.page_source, "lxml")
past = doc.find_all("div", class_ = "gameLatest gameLatestHorizontal lastestHistory")
e = past[0].find_all("div", class_="gameLatestItem")
last_3 = e[-3:]
for number in last_3:
lex = float(number.text)
if lex > 2:
weed = round(float(number.text)/25, 2)
coolsex = coolsex - weed
else:
weed = round(float(number.text)/20, 2)
coolsex = coolsex + weed
if coolsex < 1:
coolsex = 0
if lex > 2.2:
crack = crack + 1
elif lex < 1.7:
crack = crack - 1
if crack < 1:
crack = 1
meth = discord.Colour.green()
if crack == 1:
meth = discord.Colour.green()
elif crack == 2:
meth = discord.Colour.blue()
elif crack >= 3:
meth = discord.Colour.red()
else:
print('ok')
boss = round(coolsex, 2)
embed = discord.Embed(
title = boss,
colour = meth
)
await message.channel.send(embed=embed)
client.run(os.getenv('TOKEN'))```
Hello everyone, I have a question what attribute should I write so that the bot writes a message and after the user right-clicked on this message he chose "reply" only then the bot started writing another
i dont see why it wouldnt work but, why are you using time.sleep and no commands?
wym no commands
and you can always use dict's or match and case blocks
. is your prefix i suppose so why not use the command abstraction thats available?
this not working ๐ญ py await kick(user3, server, reason=self.description.value)
it say await kick is not understandable
its a method of Guild
how example pls ?

LOl
looks like low level shit posting to me
wdym? how come
So, i don't know for sure if this is the issue
then continues by showing an example of "it works on my machine", i dont even know what he means at all, im confused on what his point and solution is.
btw, ur games looks nice
