#🔒 code error for discord bots
49 messages · Page 1 of 1 (latest)
@gloomy flax
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.
(???
how are you going to write all that in python that fast
There are literally placeholder urls in the screenshots
Looks like AI from all the comments ngl
if it's AI generated code i'd rather not troubleshoot that
yup
its a youtube tut
they ain't gonna teach you in both javascript and python at the same time💀
its youtube
and github
github holds free code sources
i just did a reverse look up for python code
do you even know what the code doing
yes
what does it do?
making a deposit button for paypal and also paystripe.
also a withdraw button
is that not corect?
correct
well then, send the code
okay.
(I don't guarentee I would/can help you
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'))
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.
https://developer.paypal.com/sdk/js/reference/ doesn’t look like that’s what the js sdk is for
Integrate with the PayPal Javascript SDK or React library to easily process payments on your website. Find our complete SDK documentation here.
thats the code
!pypi paypalrestsdk
is that the issue?
is this what makes the code work?
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
AI enough
Yup
(Imagine expecting us to believe github have the exact same placeholder url as the youtube tutorial
Also who would trust this bot enough to make an actual PayPal/stripe transaction with their actual PayPal/stripe account?
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.