#🔒 code error for discord bots

49 messages · Page 1 of 1 (latest)

gloomy flax
#

my commands wont work

dreamy talonBOT
#

@gloomy flax

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dire moth
#

this is a javascript bot

#

this is a python server

gloomy flax
#

ok wait

#

let me write it in python

#

1 second

opaque solstice
#

(???

dire moth
#

how are you going to write all that in python that fast

floral helm
#

There are literally placeholder urls in the screenshots

#

Looks like AI from all the comments ngl

dire moth
#

if it's AI generated code i'd rather not troubleshoot that

opaque solstice
#

probably, either AI or some tutorial

#

more likely ai

floral helm
#

yup

gloomy flax
#

its a youtube tut

opaque solstice
#

they ain't gonna teach you in both javascript and python at the same time💀

gloomy flax
#

its youtube

#

and github

#

github holds free code sources

#

i just did a reverse look up for python code

opaque solstice
#

do you even know what the code doing

gloomy flax
#

yes

opaque solstice
#

what does it do?

gloomy flax
#

making a deposit button for paypal and also paystripe.

#

also a withdraw button

#

is that not corect?

#

correct

opaque solstice
#

well then, send the code

gloomy flax
#

okay.

opaque solstice
#

(I don't guarentee I would/can help you

gloomy flax
#

no worries.

#

import discord
import paypalrestsdk
import os
from dotenv import load_dotenv

Load environment variables from .env file

load_dotenv()

PayPal configuration

paypalrestsdk.configure({
'mode': 'sandbox', # Change to 'live' for production
'client_id': os.getenv('PAYPAL_CLIENT_ID'),
'client_secret': os.getenv('PAYPAL_CLIENT_SECRET')
})

Create a new Discord client instance

intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
client = discord.Client(intents=intents)

Event: Runs when the bot is successfully logged in and ready

@client.event
async def on_ready():
print('Bot is online and ready!')

Event: Listens for messages in Discord channels

@client.event
async def on_message(message):
# Avoid responding to messages from bots
if message.author.bot:
return

# PayPal payment command
if message.content.startswith('!deposit_paypal'):
    parts = message.content.split()
    if len(parts) != 2:
        await message.channel.send('Please provide a valid amount.')
        return

    try:
        amount = float(parts[1])  # User provides the amount after the command
    except ValueError:
        await message.channel.send('Please provide a valid amount.')
        return

    if amount <= 0:
        await message.channel.send('Please provide a valid amount.')
        return

    create_payment_json = {
        "intent": "sale",
        "payer": {
            "payment_method": "paypal"
        },
        "redirect_urls": {
            "return_url": "https://your-return-url.com/success",  # Replace with your actual return URL
            "cancel_url": "https://your-return-url.com/cancel"  # Replace with your actual cancel URL
        },
        "transactions": [{
            "amount": {
                "currency": "USD",
                "total": str(amount)
            },
            "description": "Discord bot payment"
        }]
    }

    payment = paypalrestsdk.Payment(create_payment_json)
    if payment.create():
        approval_url = next((link.href for link in payment.links if link.rel == 'approval_url'), None)
        if approval_url:
            await message.channel.send(f'Please complete the payment using this link: {approval_url}')
        else:
            await message.channel.send('An error occurred while creating the payment. Please try again later.')
    else:
        await message.channel.send('An error occurred while creating the payment. Please try again later.')
        print('PayPal Error:', payment.error)

Log the bot in using the token from the .env file

client.run(os.getenv('DISCORD_BOT_TOKEN'))

dreamy talonBOT
#

Hey @gloomy flax!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
floral helm
floral helm
#

!pypi paypalrestsdk

dreamy talonBOT
gloomy flax
#

is that the issue?

gloomy flax
floral helm
#

Mate this is the library you are using to interact with PayPal

#

Looks like it’s deprecated

#

Also notice how your redirect urls are placeholder

opaque solstice
#

AI enough

floral helm
#

Yup

opaque solstice
#

(Imagine expecting us to believe github have the exact same placeholder url as the youtube tutorial

quiet kindle
dreamy talonBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.