#discord-bots

1 messages ยท Page 76 of 1

hushed galleon
analog aurora
#

DONE

analog aurora
#

how to repair it

steep estuary
#

help please

#

!d discord.Message

unkempt canyonBOT
#

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.
glad cradle
analog aurora
#

help me out plz

glad cradle
#

stop spamming the same image, that's not the right channel

steep estuary
#

using this

analog aurora
steep estuary
#

ok no [discord.Message]=None ?

glad cradle
slate swan
#

new slash command? that doesn't really make sense at all

glad cradle
#

you can use mess_id: int and then fetch or get the message with the id

steep estuary
#

then what i should do ?

steep estuary
slate swan
#

what do you even gonna pass for a Message object conversion

glad cradle
sick birch
#

If you want a message object as a parameter for a command, a message context menu might be what you're looking for

slate swan
#

message context menu?

glad cradle
#

btw it's message commands

glad cradle
slate swan
#

?

#

message commands?

#

you mean prefix commands?

steep estuary
#

literally i am opening my bot script after months there are 100+ commands i don't know what to do

glad cradle
#

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

slate swan
#

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

vale wing
glad cradle
#

I can't see them in discordpy docs

#

maybe it's not implemented yet

vale wing
#

L

glad cradle
#

!d disnake.MessageCommand

unkempt canyonBOT
glad cradle
#

!d disnake.UserCommand

unkempt canyonBOT
vale wing
#

!d discord.app_commands.context_menu perhaps it's called like this in dpy

unkempt canyonBOT
#

@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...
vale wing
#

They appear when you click on user

slate swan
#

then what is different between user and message cmd

vale wing
vale wing
slate swan
#

hurts my brain, I think I understood

glad cradle
#

sus

slate swan
#

how do I add buttons to an embed?

paper sluice
#

!d discord.ui.View

unkempt canyonBOT
#

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.
slate swan
#

huh

#

inherited?

paper sluice
#

you add buttons to the view, then you send the view with the embed

slate swan
#

is there like a code snippet I can see

slate swan
#

@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

unkempt canyonBOT
#

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.
honest shoal
hollow agate
slate swan
hollow agate
#

Print wel[0] and see what the outcome is

slate swan
#

I want to know what message this button is on

#

nvm i got it

honest shoal
primal token
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

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.
honest shoal
#

pithinkbtw, ur games looks nice

#

I would like to try it when it is finished

primal token
#

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

paper sluice
unkempt canyonBOT
slate swan
slate swan
#
@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

paper sluice
slate swan
#

they are

honest shoal
paper sluice
#

change their names

slate swan
#

OH IM SO DUMB, THANK YOU

slate swan
primal token
#

bruh, i forgot discord always puts the first text to the far left in a codeblock for no reason

slate swan
#

also i forgot to put this in

class Button(discord.ui.View):
    def __init__(self) -> None:
        super().__init__(timeout=None)
primal token
#

why does it not keep the state in a codeblock tho

slate swan
#

okay im gonna go but thanks yall

paper sluice
primal token
#

if you try to send the message would be

>>>          w
w
paper sluice
#
    def foo(self): ...
    def bar(self): ...
primal token
#

what

slate swan
primal token
#

discord is confusing me to a point its insane

primal token
slate swan
primal token
paper sluice
#

when you copy text like this, thats when that problem happens

primal token
slate swan
primal token
#

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:

paper sluice
#

๐Ÿ‘€

#

discord on mobile is kinda bad ngl

primal token
#

I had full on stroke because of it kek

paper sluice
primal token
#

anyways sorry for the confusion i will now go install revolt

paper sluice
#

all good xD

primal token
#

๐Ÿฅฒ

gentle eagle
#

use an instance of Guild

#

!d discord.Interaction.guild

unkempt canyonBOT
gentle eagle
#

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]))
slate swan
#

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)

gentle eagle
#

Yes, but you should use my check ;33

paper sluice
#
wel = ...
...
come = ...

๐Ÿ˜ณ

gentle eagle
#

the channel isnt in the guild

honest shoal
#

looks like msg id
edit: ok channel id's digits got increased now

gentle eagle
#

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!

glad cradle
#

wel

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

glad cradle
#

where's wel

#

have you printed it?

#

are you fetching a channel?

#

send the output

#

send your current code

analog aurora
#

help plz

onyx cipher
slate swan
#

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)

onyx cipher
# onyx cipher

I made a seperate file to run my bots for me, It send this error

glad cradle
#

print wel before fetching the channel

glad cradle
analog aurora
#

idj

#

idk

glad cradle
analog aurora
glad cradle
#

!pypi PIL

unkempt canyonBOT
glad cradle
unkempt canyonBOT
analog aurora
# glad cradle `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)

silk fulcrum
analog aurora
silk fulcrum
silk fulcrum
analog aurora
#

i cant install it

silk fulcrum
#

wdym

analog aurora
#

how man plz tell me

silk fulcrum
#

pip install PIL

analog aurora
#

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)

silk fulcrum
#

that is Pillow ig

slate swan
analog aurora
#

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>

silk fulcrum
ashen perch
#

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)
silk fulcrum
#

it uses a PIL namespace

analog aurora
#

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)

silk fulcrum
#

weird

glad cradle
#

probably it's a path issue

#

pain

silk fulcrum
#

oh yeah could be

glad cradle
analog aurora
#

idk im new in it

silk fulcrum
analog aurora
ashen perch
silk fulcrum
#

hybrid command and app commands together (well that shouldnt be a problem)

#

not syncing a tree

#

idk idk

glad cradle
analog aurora
glad cradle
analog aurora
glad cradle
#

yes, check the system path

analog aurora
#

how man

analog aurora
glad cradle
# analog aurora how man
#

ignore the oracle instructions to add their path

#

btw you can see the paths in the same way

analog aurora
glad cradle
scarlet aurora
#
    @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

slate swan
#

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(),
        ))
torn sail
scarlet aurora
#

alright thanks

torn sail
slate swan
#

What does that do

torn sail
#

Sorry I meant add it

#

It will make the interaction failed go away

scarlet aurora
slate swan
#

ok

torn sail
scarlet aurora
#

then what do I put below that

#

where print("Works") is

torn sail
#

Well do you wanna skip the user if they have the bot blocked or dms off?

scarlet aurora
#

yeah skip

torn sail
#

The just put pass

scarlet aurora
#

ok

torn sail
scarlet aurora
#

that's a smart idea ๐Ÿคฃ

#

lol ty

austere vale
#
  @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?

potent spear
austere vale
#

o alright

potent spear
#

also, if you're returning in an if statement, you don't need the elif

#
if shit:
  # ...
  return
elif other_shit:
  #...```
austere vale
#

i see

potent spear
#

is basically

if shit:
  # ...
  return
if other_shit:
  # ...```
austere vale
#

thank you

primal token
slate swan
#

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

potent spear
#

true, you could still see the connection

potent spear
potent spear
#

let's say 100 members play that game at once, can you imagine?

#

you make another game

slate swan
#

wait like

#

100 people play one snake game or 100 people play 100 different snake games @potent spear

potent spear
#

the latter

primal token
slate swan
#

๐Ÿ˜ฆ

potent spear
#

yeah, "at the same time"

slate swan
#

How about I set a limit on how many snake games can be played in the server

potent spear
#

max_concurrency is a decorator which you can put on top of a command

slate swan
#

What does it do

potent spear
#

the docs will tell you

slate swan
#

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()?

slate swan
#

I handle each game in a class.

potent spear
#

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?

slate swan
#

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

slate swan
#

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

potent spear
#

put what?

slate swan
#

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

potent spear
#

Well, obviously you want to prevent members from creating games

slate swan
#

Okay.

#
@Arcade.tree.command()
@commands.max_concurrency(5, wait=False)

Done.

potent spear
#

you still have to add a per kwarg

slate swan
#

commands.BucketType.User

#

wait no guild

potent spear
#

try and see

slate swan
#

.guild takes too long

#

now i cant move it much

#

I think .channel would be good

potent spear
#

try and see, that's all I can say

slate swan
#

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

potent spear
#

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...

slate swan
#

I've made one before, I just used a different method this time but now

potent spear
#

instantly implementating it in dpy is mostly a bad idea

hybrid fjord
#

How to check if someone pinged someone with a reply?

primal token
unkempt canyonBOT
#

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.

slate swan
#

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

primal token
slate swan
#

i got it

#

for sum reason it doesnt like datetime.datetime

#

i just used datetime.now() and now it works

primal token
#

i suppose you did

from datetime import datetime
slate swan
#

yea

#

i have that

primal token
#

it just doesnt have ClassNaming

slate swan
#

ah

slate swan
#

I did it! I finished the snake bot ๐Ÿ™‚

#

Now to add some more games

vestal dagger
slate swan
#

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

boreal ravine
#

If you make it move constantly you'll have a chance to get rate limited

flat solstice
#

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

slate swan
boreal ravine
slate swan
#

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?

boreal ravine
#

Maybe

#

You could add a cooldown to it

slate swan
#

As in?

#

I don't understand sorry

#

Like a cooldown for making the game?

boreal ravine
slate swan
#

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

dull terrace
#

on a scale of 1 to 10 how bad is it to name a class get

fast vortex
#

As in very very bad

fast vortex
# slate swan actually too complicated ๐Ÿ˜›

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

fast vortex
sage otter
#

Eyyy itโ€™s Kraots

#

Was wondering when you would appear again.

fast vortex
fast vortex
fast vortex
sage otter
slate swan
sage otter
#

Who knows man

fast vortex
#

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

slate swan
#

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")
wicked atlas
sick birch
slate swan
austere vale
#

could somoene help me please? i cant find this file and im trying to delete it so my music code can work again

slate swan
#

@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.

raven bolt
#

is this an okay purge command?

#

in a cog in this case.

slate swan
austere vale
#

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

slate swan
#

damn it

raven bolt
slate swan
#

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

quaint epoch
#

bad bot

austere vale
#

my console is spamming this and i cant turn off the bot. any way to fix?

slate swan
#

how do i get the guild id of a server my bot is in?

sick birch
austere vale
#

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)
austere vale
#

ye i tried that but it just turned itself back on and kept spamming

quaint epoch
#

rip

slate swan
sick birch
slate swan
#

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.

sick birch
#

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

slate swan
#

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.

boreal ravine
heady citrus
#

How would i make my bot ignore users thats above the bot in the tole hierarchy

slate swan
#

How can I

#

find the severid a player is in

unkempt canyonBOT
crimson plover
jagged adder
#

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

silk fulcrum
unkempt canyonBOT
#

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

heady citrus
fickle hamlet
slate swan
#

ansi code blocks won't work for mobile users

silk fulcrum
heady citrus
#

@silk fulcrum would self.bot.top_role work since its in a listener

fickle hamlet
#

But having them is a nice touch, you can always encapsulate with an embed

silk fulcrum
#

you need guild.me

slate swan
silk fulcrum
#

what does that mean

heady citrus
#

wrong i misread

#

would this work @slate swan

silk fulcrum
#

channel.guild.me*

heady citrus
silk fulcrum
#

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

heady citrus
#

thats the point

silk fulcrum
#

ok

heady citrus
vocal snow
#

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 shrug

#

or the channel belongs to another guild

mossy jacinth
#

how can i delete the message the user sent?

naive briar
mossy jacinth
#

๐Ÿ’€ thanks didnt know

vocal snow
#

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?

ashen perch
#

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)
vocal snow
#

dont pass guild id as str

#

!d discord.ext.commands.hybrid_command

unkempt canyonBOT
#

@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.
vocal snow
#

and with_app_command is True by default

mossy jacinth
#

is it possible to use ctx in a loop?

vocal snow
mossy jacinth
vocal snow
#

just as you would pass an argument to any function

ashen perch
ashen perch
#

K Iโ€™ll try that later thanks

#

Also is this because commands now need to be registered?

vocal snow
#

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

paper sluice
#

you didn't specify the datatype for guildID

vocal snow
#

CREATE TABLE Welcome (
    guild_id BIGINT PRIMARY KEY,
    channel_id BIGINT,
    msg TEXT
);
cloud dawn
#

May I ask why people are using create table inside their python code?

vocal snow
#

To make SQL table

cloud dawn
#

What database needs that?

#

Since almost every SQL type I know can you make predefined tables.

vocal snow
#

What

#

Now let's see the code you're using for insertion

maiden fable
#

๐Ÿซก

rugged shadow
#

who knows, maybe it's open source

#

but a better option would be an init.sql

placid skiff
#

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

mossy jacinth
#

did i do anything wrong

naive briar
#

I can't see the whole error messages

civic fractal
unkempt canyonBOT
#

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.

mossy jacinth
mossy jacinth
slate swan
#

how to keep a discord bot online without replit?

#

replits 429 error annoys me

silent portal
slate swan
mossy jacinth
#

Writing a new confession deletes the old one... How can i fix that?

naive briar
#

Instead of w

mossy jacinth
#

thanks

silent portal
#

best option

slate swan
#

too broke

silent portal
#

but it costs mine is small i pay like 4$ a month

silent portal
slate swan
#

massive..

silent portal
#

:(

#

sry

#

you could try heroku

#

itโ€˜s kinda like replit but you only have 20 days/month or smth

maiden fable
silent portal
silent portal
rugged shadow
shrewd apex
#

sounds creepy

rugged shadow
#

frfr

shrewd apex
robust fulcrum
#
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?

maiden fable
#

Why r u manually sending requests tho

robust fulcrum
vale wing
#

Also it is Bot token.goes.here

#

So you gotta use it like

headers = {"Authorization": f"Bot {token}"}```
robust fulcrum
rugged shadow
maiden fable
robust fulcrum
boreal ravine
#

How do I fix an SSL error? I get it when I'm starting my bot

paper sluice
#

whats the error, send traceback

boreal ravine
boreal ravine
# paper sluice <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.
boreal ravine
paper sluice
silk fulcrum
#

i think there was a pin about that

boreal ravine
#

That caused the error

slate swan
# slate swan how to keep a discord bot online without replit?

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.

slate swan
#

so I need to host bot for free with no crash

night crater
glad cradle
vale wing
vale wing
primal token
glad cradle
rugged tulip
timber wren
#

guys, how do I get the name of the vc a member is in?

vocal snow
#

!d discord.Member.voice

unkempt canyonBOT
vocal snow
#

This returns VoiceState which has a channel attr

silent portal
#

mc-host24

rugged tulip
#

ahhh, interesting

rugged tulip
silent portal
#

yw

slate swan
upbeat gust
patent skiff
#

xcuseme

hybrid fjord
#

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

vocal snow
#

on_message is only way afaik

#

you can check reply mentions with message.reference

slate swan
#

.mentions returns both replies and mentions iirc

vocal snow
#

!d discord.Message.mentions

unkempt canyonBOT
#

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.

vocal snow
#

oh this is convenient attr

analog aurora
#

hi can anyone help me write python script

#

i need to create script that would add "credits" to people with command

slate swan
glad cradle
slate swan
glad cradle
# slate swan

have you enabled message_content intent on the discord developer website?

slate swan
#

yep

#

i fixed it

#

async def add(ctx, member: discord.Member, *, reason) -> None:

#

this will work?

glad cradle
#

why it shouldn't

analog aurora
#

hi is there someone who can help me write a discord bot command in python

analog aurora
#

i got an gambling discord bot

#

and i want to create a command witch add people coins

#

like $add @analog aurora 1000

slate swan
#

you have to use a database as excpected

analog aurora
#

i got

#

but iam noobie scripting

slate swan
#

which one ?

analog aurora
#

sqlite3

slate swan
#

you can use 'tinydb' it's easier

analog aurora
#

.

#

i got some commands from my friend and i want create a new one but im so bad at it

crystal cliff
slate swan
analog aurora
#

nothing i dont know how to start write it

#

yea it is

#

thats some sample

crystal cliff
slate swan
analog aurora
#

i need to create new file .py?

#

ok done

crystal cliff
analog aurora
#

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>

normal lance
#

Write in cmd:

pip install pillow
analog aurora
#

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

quaint epoch
#

!dashmpip

unkempt canyonBOT
#
Install packages with `python -m pip`

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.

quaint epoch
#

Py 3.7 -m pip install pillow

analog aurora
#

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>

quaint epoch
#

This is why venvs exist

analog aurora
#

C:\Users\jakub>python3.7
'python3.7' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\jakub>

analog aurora
# normal lance Py3.7

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>

normal lance
#

@analog aurora how do you launch a bot?

slate swan
#

Anyone know what this error means?
TypeError: TypedDict does not support instance and class checks

analog aurora
#

what do you mean

#

maybe an good option is delete 3.10\

slate swan
analog aurora
#

give me commands i will type in

#

@slate swan give me commands to delete 3.10

normal lance
analog aurora
#

i uninstalled ir

#

none

slate swan
analog aurora
#

got diffrent language but that system?

rare echo
#

cant just?

analog aurora
#

11

rare echo
analog aurora
rare echo
analog aurora
#

yea

rare echo
#

then make it longer and send ss

#

ofc blocking out whatever you need

analog aurora
rare echo
#

just seeing that above ss its not added

slate swan
#

what is he trying to do?

#

oh he needs an interpreter?

rare echo
# analog aurora

C:\Users\jakub\AppData\Local\Programs\Python\{your python version which if i saw was 3.7?}\Scripts

analog aurora
#

yea it was 3.7

#

can you write it corect

rare echo
#

new >

C:\Users\jakub\AppData\Local\Programs\Python\Python37\Scripts

analog aurora
#

done

rare echo
analog aurora
#

C:\Users\jakub>python --version

C:\Users\jakub>

#

says none

rare echo
analog aurora
#

c,d

#

cmd

rare echo
#

do python with no arg

analog aurora
#

it got me microsoft store

rare echo
#

x)

analog aurora
#

maybe need to reinstall python

#

oh

paper sluice
#

just do pip list > req.txt

analog aurora
#

i mean idk what i have

rare echo
#

if you are going to go to the extent of reinstalling you may as well switch to a venv

paper sluice
analog aurora
#

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>

paper sluice
#

powershell is cringe, do it in cmd

#

ah, python -m pip then

analog aurora
#

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>

rare echo
paper sluice
#

breh

rare echo
#

i got work lads i wish ya luck

analog aurora
#

bye

paper sluice
#

@analog aurora install python from python.org and run the executable as admin

analog aurora
#

like i know what pip i got it in file

#

kk

slate swan
#

the bot has access to that channel?

#

in your await cursor.execute(INSERT INTO welcome..., what is ON DUPLICATE KEY MSG.. for?

slate swan
slate swan
analog aurora
#

i click it when installer wasx

slate swan
#

so, you're wanting to update your database when a new person joins?

analog aurora
#

it cant boot even now

slate swan
analog aurora
#

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>

slate swan
paper sluice
#

most discord wrappers require python 3.8 or above

slate swan
#

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

slate swan
#

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

paper sluice
slate swan
#

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 !

primal token
#

should also use annotations

slate swan
#

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

primal token
slate swan
#
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

vale frigate
#

guys how get id of ownership of the server?

#

user2 = bot.get_user()

#

idk

vale frigate
#

ah

quaint epoch
#

Well that should work

vale frigate
#

?

quaint epoch
#

!d discord.Guild.owner

unkempt canyonBOT
vale frigate
#

so user2 = discord.Guild.owner.id ok

slate swan
#

i think

#

thats how my server info command is done

vale frigate
#

ok

slate swan
#

or you can do

user2 = ctx.guild.owner_id

vale frigate
#

OK!!

summer flume
#

do anyone know how is this thing called?

<t:1171717171>

summer flume
#

tysm

tired wedge
cold sonnet
#

why is bro named server

#

and role named user

#

it's if role_instance in member_instance.roles

slate swan
#

AND HOW WOULD I USE THAT

#

caps

#

hm, is there a way to make a function run just like setup_hook?

paper sluice
#

like which is called once right before startup?

silk fulcrum
#

no such channel with id int(come[id]) ๐Ÿ—ฟ

#

๐Ÿ—ฟ how do i know

slate swan
#

how do i use role_instance in member_instance.roles

silk fulcrum
#

i don't know what channel you want ๐Ÿ—ฟ

silk fulcrum
#

replace role_instance with Role instance and member_instance with Member instance

paper sluice
#

why do you have ids of the channels which don't exist in the first place?

silk fulcrum
slate swan
#

no

paper sluice
#

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

silk fulcrum
slate swan
paper sluice
#

you are inserting self.channel.id, is self.channel changing or is it same throughout?

silk fulcrum
slate swan
silk fulcrum
#

cus russians build sentences with lots of negatives

#

like "I don't know nothing" (if translating word by word)

silk fulcrum
slate swan
paper sluice
#

what did you change?

silk fulcrum
#

wdym "time string"

outer parcel
#

store a time as an epoch

paper sluice
silk fulcrum
#

sql databases can store DATE or TIME or even DATETIME iirc

outer parcel
#

You can store in database like

paper sluice
#

well, first try to fix the original problem

silk fulcrum
#

storing timestamps ๐Ÿ’€

#

well probably that is possible

outer parcel
#

and format it like this when you are asccessing it

#

and you get this

paper sluice
#

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

primal token
# slate swan no

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

slate swan
#

im not gonna learn a whole coding language ๐Ÿ—ฟ

paper sluice
slate swan
#

still

vale frigate
#

how kick some one by discord bot??

#

kick {member}?

paper sluice
#

its just some basic concepts which you need to learn before making a discord bot.

vale frigate
#

idk

paper sluice
#

!d discord.Member.kick

unkempt canyonBOT
#

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").
vale frigate
primal token
#

ch can be a literal of NoneType as the method being used has a return type of a -> None |abc.GuildChannel | Thread | abc.PrivateChannel

vale frigate
primal token
#

nothing i only know lua

vale frigate
#

not any server

primal token
#

?

slate swan
primal token
slate swan
#

also how do you do that reply thing

primal token
#

> text

slate swan
#

oh

primal token
#

You make a check?

vale frigate
#

@paper sluice any idea?

primal token
#

you can use or

#

!e

print(None or 1)
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

1
primal token
#

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

unkempt canyonBOT
#

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.
paper sluice
vale frigate
#

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

primal token
#

it depends on which instance you use the method on?

paper sluice
vale frigate
paper sluice
#

!d discord.Guild.kick

unkempt canyonBOT
#

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.
primal token
#

?

vale frigate
#

i want other server

vale frigate
primal token
vale frigate
paper sluice
primal token
vale frigate
#

jjust

#

me want do in server a

#

/kick Some one

#

and be kicked in server b

honest shoal
#

how do I check if command message is replied to another msg

vale frigate
#

IDK

honest shoal
#

so that bot can reply to the same message I replied

vale frigate
#

like await kick(user, {{server}, reason=None)

#

or what

honest shoal
primal token
unkempt canyonBOT
#

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.

vale frigate
honest shoal
primal token
#

!d discord.MessageReference

unkempt canyonBOT
#

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.
vale frigate
primal token
#

?

vale frigate
#

i still not understand ๐Ÿ˜ฆ

honest shoal
primal token
honest shoal
vale frigate
#

OH

#

then guild = server

#

then guild.kick???

primal token
#

where would server be defined and why make another pointer?

vale frigate
#

yes

honest shoal
#

OH, there's one .resolved

primal token
honest shoal
#

I'm confused

vale frigate
#

!kick

south brook
#

Can you sent the current status of a user?

#

(In a command)

primal token
#

!d discord.Member.status

unkempt canyonBOT
#

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.
south brook
#

How do i use this inside an command?

primal token
#

You just get an instance of Member?

south brook
#

like this? a = await client.fetch_user(584748051814547487)

#

and then await ctx.send(str(a.status)) ?

south brook
#

oh

primal token
#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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.
primal token
#

if you want a certain member always

#

you can always use an argument or the author, it depends on what you want

south brook
#

so await fetch_member(id)

south brook
primal token
#

do you want always a certain user?

south brook
#

yes

primal token
south brook
#

ok

#

fetch member is not defined

primal token
# south brook yes

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

primal token
south brook
#

i am

primal token
#

and you also have to use it in an instance

#

!d discord.ext.commands.Context.guild

south brook
#

instance?

unkempt canyonBOT
south brook
#

Can you please send the code for this?

primal token
#

I already have given you what you need?

south brook
#

Yes, but i dont get it

primal token
#

What do you not get?

south brook
#

everything lmao

primal token
#

Well do you know about python's OOP?

south brook
#

?

primal token
#

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

slate swan
#

bruh my bot works in dms but not on my server

#

anyone know why?

primal token
#

can you show your code?

silk fulcrum
#

message content intent? :hm:

slate swan
primal token
silk fulcrum
#

uh oh

primal token
#

he should have the message content intent as the command is getting invoked in dms

slate swan
primal token
#

just name them what they represent?

#

e.g

cool_number = 69
silk fulcrum
slate swan
primal token
#

?

silk fulcrum
#
ั‹ = await forever_coro_with_yomama(123456)``` that's how you call vars @primal token
#

just ั‹

primal token
#

ok

silk fulcrum
#

or ัŠัƒัŠ

slate swan
#
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'))```
light jungle
#

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

primal token
primal token
#

and you can always use dict's or match and case blocks

primal token
slate swan
#

what does that mean

#

whatever

#

that doesnt matter but why does it only work in dms

vale frigate
#

this not working ๐Ÿ˜ญ py await kick(user3, server, reason=self.description.value)

#

it say await kick is not understandable

vale frigate
#

how example pls ?

vocal snow
vale frigate
#

LOl

slate swan
#

@primal token sorry for ping but

#

someone said this

#

what does it mean

primal token
#

looks like low level shit posting to me

slate swan
primal token
#

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.