I have Make a python Discord bot but problem !

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üye
Katılım
20 Ara 2019
Mesajlar
6
Tepki puanı
1
Ödüller
4
Yaş
27
6 HİZMET YILI
I have made a python discord bot which help me to boost servers with token but sometimes it give me error like it only boost with 1 token and then it stop can you help to fix it!!!

Code
Rich (BB code):
from discord.ext import commands
import discord, os, json, hashlib
from boosting import *
# from pipscrape import color
from auto import *
if os.name == 'nt':
    import ctypes

config = json.load(open("config.json", encoding="utf-8"))

def clear(): #clears the terminal
    os.system('cls' if os.name =='nt' else 'clear')
    
    

if os.name == "nt":
    ctypes.windll.kernel32.SetConsoleTitleW(f"Boost Bot")
else:
    pass



activity = discord.Activity(type=discord.ActivityType.watching, name=config["bot_status"])
bot = commands.Bot(command_prefix = ">", intents = discord.Intents.all(), activity = activity)
    
    
@bot.event
async def on_ready():
    sprint(f"{bot.user} is online!", True)
    
    
@bot.slash_command(guild_ids=[config["guildID"]], name="ping", description="Check the bot's latency.")
async def ping(ctx):
    await ctx.respond(embed = discord.Embed(title = "**Pong!**", description = f"{round(bot.latency * 1000)} ms", color = 0x4598d2))
    
    
@bot.slash_command(guild_ids=[config["guildID"]], name="restock", description="Allows one to restock 1 month or 3 month nitro tokens.")
async def restock(ctx, code: discord.Option(str, "Paste.ee link", required = True),type: discord.Option(int, "Type of tokens you are restocking, 3 months or 1 month", required=True)):
    if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
        return await ctx.respond(embed = discord.Embed(title = "**Missing Permission**", description = "You must be an owner or an administrator to use this command!", color = 0xc80000))
    if type != 1 and type != 3 and type != 0:
        return await ctx.respond(embed = discord.Embed(title = "**Invalid Input**", description = "Type can either be 3 (months), 1 (month) or empty", color = 0xc80000))
    if type == 1:
        file = "input/1m_tokens.txt"
    elif type == 3:
        file = "input/3m_tokens.txt"
        
    
    code = code.replace("https://paste.ee/p/", "")
    temp_stock = requests.get(f"https://paste.ee/d/{code}", headers={ "User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36"}).text;fingerprint_modification()
    
    f = open(file, "a", encoding="utf-8")
    f.write(f"{temp_stock}\n")
    f.close()
    lst = temp_stock.split("\n")
    return await ctx.respond(embed = discord.Embed(title = "**Success**", description = f"Successfully added {len(lst)} tokens to {file}", color = 0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="addowner", description="Adds an owner.")
async def addowner(ctx, member: discord.Option(discord.Member, "Member who has add to be added as an owner.", required = True)):
    if ctx.author.id not in config["ownerID"]:
        return await ctx.respond(embed = discord.Embed(title = "**Missing Permissionn**", description = "You must be an owner to use this command!", color = 0xc80000))
    
    config["ownerID"].append(member.id)
    with open('config.json', 'w') as f:
        json.dump(config, f, indent = 4)
        
    return await ctx.respond(embed = discord.Embed(title = "**Success**", description = f"Successfully added {member} ({member.id}) as an owner.", color = 0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="addadmin", description="Adds an admin.")
async def addadmin(ctx, member: discord.Option(discord.Member, "Member who has add to be added as an admin.", required = True)):
    if ctx.author.id not in config["ownerID"]:
        return await ctx.respond(embed = discord.Embed(title = "**Missing Permissionn**", description = "You must be an owner to use this command!", color = 0xc80000))
    
    config["adminID"].append(member.id)
    with open('config.json', 'w') as f:
        json.dump(config, f, indent = 4)
        
    return await ctx.respond(embed = discord.Embed(title = "**Success**", description = f"Successfully added {member} ({member.id}) as an owner.", color = 0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="stock", description="Allows you to see the current stock.")
async def stock(ctx):
    three = len(open("input/3m_tokens.txt", "r").readlines())
    one = len(open("input/1m_tokens.txt", "r").readlines())
    return await ctx.respond(embed = discord.Embed(title = "**Stock**", description = f"**3 Months Tokens Stock:** {three}\n**3 Months Boosts Stock:** {three*2}\n\n**1 Month Tokens Stock:** {one}\n**1 Month Boosts Stock:** {one*2}", color = 0x4598d2))

    
@bot.slash_command(guild_ids=[config["guildID"]], name="boost", description="Boosts a discord server.")
async def boost(ctx, invite: discord.Option(str, "Invite link to the server you want to boost.", required = True), amount: discord.Option(int, "Number of times you want to boost the sever.", required = True), months: discord.Option(int, "Number of months you want to boost the server for 1 or 3.", required = True),nick: discord.Option(str, "Nickname you want to set for the boosting account.", required = False) = config['server_nick']):
    if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
        return await ctx.respond(embed = discord.Embed(title = "**Missing Permission**", description = "You must be an owner or an administrator to use this command!", color = 0xc80000))
    if months != 1 and months != 3:
        return await ctx.respond(embed = discord.Embed(title = "**Invalid Input**", description = "Months can either be 3 (months) or 1 (month).", color = 0xc80000))
    if amount % 2 != 0:
        return await ctx.respond(embed = discord.Embed(title = "**Invalid Input**", description = "Amount needs to be even", color = 0xc80000))
    if months == 1:
        filename = "input/1m_tokens.txt"
    if months == 3:
        filename = "input/3m_tokens.txt"
    
    if checkEmpty(filename):
        return await ctx.respond(embed = discord.Embed(title = "**Stock Error**", description = "There is currently no stock in the files. Please use /restock to add nitro tokens in the stock files.", color = 0xc80000))
    if len(open(filename, "r").readlines()) < amount / 2:
        return await ctx.respond(embed = discord.Embed(title = "**Stock Error**", description = "There is currently not enough stock in the files. Please use /restock to add nitro tokens in the stock files.", color = 0xc80000))
    
    invite = getinviteCode(invite)
    
    if validateInvite(invite) == False:
        return await ctx.respond(embed = discord.Embed(title = "**Invite Error**", description = "The invite submitted is invalid. Please sumbit a valid invite link.", color = 0xc80000))
    
    await ctx.respond(embed = discord.Embed(title = "**Boosts Started**", description = f"**Invite Link: **https://discord.gg/{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months", color = 0x4598d2))
    print()
    sprint(f"Boosting https://discord.gg/{invite}, {amount} times for {months} months", True)
    start = time.time()
    boosted = thread_boost(invite, amount, months, nick)
    end = time.time()
    time_taken = round(end - start, 2)
    
    if boosted == False:
        with open('success.txt', 'w') as f:
            for line in variables.success_tokens:
                f.write(f"{line}\n")
        
        with open('failed.txt', 'w') as g:
            for line in variables.failed_tokens:
                g.write(f"{line}\n")
    
    
        embed2 = DiscordEmbed(title = "**Boosts Unsuccessful**", description = f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **https://discord.gg/{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}", color = 'c80000')
        embed2.set_timestamp()
        webhook = DiscordWebhook(url=config["boost_failed_log_webhook"])
        webhook.add_embed(embed2)
        webhook.execute()
        print()
        sprint(f"Failed to Boost https://discord.gg/{invite}, {amount} times for {months} months. Operation took {time_taken} seconds", False)
        print()
        
        webhook = DiscordWebhook(url=config["boost_failed_log_webhook"])
        with open("success.txt", "rb") as f:
            webhook.add_file(file=f.read(), filename='success.txt')
        with open("failed.txt", "rb") as f:
            webhook.add_file(file=f.read(), filename='failed.txt')
        webhook.execute()
        
        os.remove("success.txt")
        os.remove("failed.txt")
        
        return await ctx.respond(embed = discord.Embed(title = "**Boosts Unsuccessful**", description = f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **https://discord.gg/{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}", color = 0xc80000))
    
    elif boosted:
        with open('success.txt', 'w') as f:
            for line in variables.success_tokens:
                f.write(f"{line}\n")
        
        with open('failed.txt', 'w') as g:
            for line in variables.failed_tokens:
                g.write(f"{line}\n")
                
        embed3 = DiscordEmbed(title = "**Boosts Successful**", description = f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **https://discord.gg/{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}", color = '4598d2')
        embed3.set_timestamp()
        webhook = DiscordWebhook(url=config["boost_log_webhook"])
        webhook.add_embed(embed3)
        webhook.execute()
        print()
        sprint(f"Boosted https://discord.gg/{invite}, {amount} times for {months} months. Operation took {time_taken} seconds", True)
        print()
        
        webhook = DiscordWebhook(url=config["boost_log_webhook"])
        with open("success.txt", "rb") as f:
            webhook.add_file(file=f.read(), filename='success.txt')
        with open("failed.txt", "rb") as f:
            webhook.add_file(file=f.read(), filename='failed.txt')
        webhook.execute()
        
        os.remove("success.txt")
        os.remove("failed.txt")
        
        return await ctx.respond(embed = discord.Embed(title = "**Boosts Successful**", description = f"**Boost Type: **Manual\n**Order ID: **N/A\n* *Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **https://discord.gg/{invite }\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{ len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}", color = 0x4598d2))
    
    
clear()
keep_alive()
fingerprint_modification()
bot.run(config['bot_token'])
 
Onaylı Üye
Katılım
13 Haz 2023
Mesajlar
52
Tepki puanı
1
Ödüller
2
Yaş
22
2 HİZMET YILI
why even using python for discord! use discord.js dude
 
Uzman Üye
Katılım
17 Tem 2020
Mesajlar
200
Çözümler
1
Tepki puanı
42
Ödüller
4
Yaş
33
5 HİZMET YILI
  1. Remove the keep_alive() function from the last line. It seems like a custom function that keeps the bot alive, but it's not included in the provided code. If you need it, make sure it's defined properly.
  2. Remove the fingerprint_modification() function call from the restock command. It's not defined in the provided code, and there's no need to include it for the fix.
  3. Check the boost command implementation. It seems like the boosting logic is happening outside of the command function in the thread_boost function. Make sure that the thread_boost function is properly implemented and handles the boosting process with multiple tokens.
you can try that:


Python:
from discord.ext import commands
import discord, os, json, hashlib

config = json.load(open("config.json", encoding="utf-8"))

def clear(): #clears the terminal
os.system('cls' if os.name =='nt' else 'clear')

if os.name == "nt":
import ctypes
ctypes.windll.kernel32.SetConsoleTitleW(f"Boost Bot")
else:
pass

activity = discord.Activity(type=discord.ActivityType.watching, name=config["bot_status"])
bot = commands.Bot(command_prefix=">", intents=discord.Intents.all(), activity=activity)

@bot.event
async def on_ready():
print(f"{bot.user} is online!")

@bot.slash_command(guild_ids=[config["guildID"]], name="ping", description="Check the bot's latency.")
async def ping(ctx):
await ctx.respond(embed=discord.Embed(title="**Pong!**", description=f"{round(bot.latency * 1000)} ms", color=0x4598d2))

@bot.slash_command(guild_ids=[config["guildID"]], name="restock", description="Allows one to restock 1 month or 3 month nitro tokens.")
async def restock(ctx, code: discord.Option(str, "Paste.ee link", required=True),
type: discord.Option(int, "Type of tokens you are restocking, 3 months or 1 month", required=True)):
if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**",
description="You must be an owner or an administrator to use this command!",
color=0xc80000))
if type != 1 and type != 3 and type != 0:
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**",
description="Type can either be 3 (months), 1 (month) or empty",
color=0xc80000))
if type == 1:
file = "input/1m_tokens.txt"
elif type == 3:
file = "input/3m_tokens.txt"

code = code.replace("https://paste.ee/p/", "")
temp_stock = requests.get(f"https://paste.ee/d/{code}",
headers={"User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36"}).text

f = open(file, "a", encoding="utf-8")
f.write(f"{temp_stock}\n")
f.close()
lst = temp_stock.split("\n")
return
 
Onaylı Üye
Katılım
30 Ağu 2021
Mesajlar
52
Tepki puanı
3
Ödüller
3
Yaş
26
4 HİZMET YILI
sorry can't help but seems like code is right
 
Banlı Üye
Katılım
25 Şub 2019
Mesajlar
309
Tepki puanı
13
Ödüller
4
Yaş
29
Sosyal
7 HİZMET YILI
Is there an error that appears in the terminal screen?
 
Onaylı Üye
Katılım
10 Eyl 2020
Mesajlar
57
Tepki puanı
3
Ödüller
3
5 HİZMET YILI
Can't even look at the code properly, where's "thread_boost" def?

For Python I'd recommend using discord.py-self by
Bağlantıları görmek için lütfen Giriş Yap
, take a look at
Bağlantıları görmek için lütfen Giriş Yap
by
Bağlantıları görmek için lütfen Giriş Yap
J (you'll need to implement it).
I don't know much about JS but, you can try this:
Bağlantıları görmek için lütfen Giriş Yap
by
Bağlantıları görmek için lütfen Giriş Yap
.

Gravekeeper at its best.
 
Uzman Üye
Katılım
14 Haz 2019
Mesajlar
151
Tepki puanı
6
Ödüller
4
6 HİZMET YILI
For discord bot use discord js rather then python its more flexible and easy to handle where the error is..
 
Süper Üye
Katılım
15 May 2019
Mesajlar
664
Çözümler
2
Tepki puanı
40
Ödüller
7
Yaş
25
7 HİZMET YILI
Did you write the code yourself or did you use someone else's?

Here are the modifications and enhancements:

Missing import statements for requests and time have been added.
For logging messages, sprint has been replaced by print.
Unused imports were removed.
The code has been updated to utilize a context manager (with open) for file operations, ensuring that files are correctly closed.
Comments have been added to clarify the code.
Unnecessary code blocks were removed.
Indentation and formatting errors have been resolved.
Please replace your previous code with this changed code, and everything should be ok. At the conclusion of the script, provide the relevant code to launch your bot.

Copy the content from this page.

from discord.ext import commands
import discord
import os
import json
import requests
import time
from discord_webhook import DiscordWebhook, DiscordEmbed

# Import required functions and variables from your modules
from boosting import *
from auto import *

config = json.load(open("config.json", encoding="utf-8"))

def clear(): # Clears the terminal
os.system('cls' if os.name == 'nt' else 'clear')

if os.name == "nt":
ctypes.windll.kernel32.SetConsoleTitleW("Boost Bot")

activity = discord.Activity(
type=discord.ActivityType.watching, name=config["bot_status"])
bot = commands.Bot(command_prefix=">", intents=discord.Intents.all(), activity=activity)

@bot.event
async def on_ready():
print(f"{bot.user} is online!")

@bot.slash_command(guild_ids=[config["guildID"]], name="ping", description="Check the bot's latency.")
async def ping(ctx):
await ctx.respond(embed=discord.Embed(title="**Pong!**", description=f"{round(bot.latency * 1000)} ms", color=0x4598d2))

@bot.slash_command(guild_ids=[config["guildID"]], name="restock", description="Allows one to restock 1 month or 3 month nitro tokens.")
async def restock(ctx, code: str, type: int):
if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**", description="You must be an owner or an administrator to use this command!", color=0xc80000))

if type not in (0, 1, 3):
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**", description="Type can either be 3 (months), 1 (month), or empty", color=0xc80000))

if type == 1:
file = "input/1m_tokens.txt"
elif type == 3:
file = "input/3m_tokens.txt"

code = code.replace("
Bağlantıları görmek için lütfen Giriş Yap
", "")
temp_stock = requests.get(f"
Bağlantıları görmek için lütfen Giriş Yap
{code}", headers={
"User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36"}).text
fingerprint_modification()

with open(file, "a", encoding="utf-8") as f:
f.write(f"{temp_stock}\n")

lst = temp_stock.split("\n")
await ctx.respond(embed=discord.Embed(title="**Success**", description=f"Successfully added {len(lst)} tokens to {file}", color=0x4598d2))

@bot.slash_command(guild_ids=[config["guildID"]], name="addowner", description="Adds an owner.")
async def addowner(ctx, member: discord.Member):
if ctx.author.id not in config["ownerID"]:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**", description="You must be an owner to use this command!", color=0xc80000))

config["ownerID"].append(member.id)
with open('config.json', 'w') as f:
json.dump(config, f, indent=4)

await ctx.respond(embed=discord.Embed(title="**Success**", description=f"Successfully added {member} ({member.id}) as an owner.", color=0x4598d2))

@bot.slash_command(guild_ids=[config["guildID"]], name="addadmin", description="Adds an admin.")
async def addadmin(ctx, member: discord.Member):
if ctx.author.id not in config["ownerID"]:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**", description="You must be an owner to use this command!", color=0xc80000))

config["adminID"].append(member.id)
with open('config.json', 'w') as f:
json.dump(config, f, indent=4)

await ctx.respond(embed=discord.Embed(title="**Success**", description=f"Successfully added {member} ({member.id}) as an admin.", color=0x4598d2))

@bot.slash_command(guild_ids=[config["guildID"]], name="stock", description="Allows you to see the current stock.")
async def stock(ctx):
three = len(open("input/3m_tokens.txt", "r").readlines())
one = len(open("input/1m_tokens.txt", "r").readlines())

embed = discord.Embed(
title="**Stock**",
description=f"**3 Months Tokens Stock:** {three}\n**3 Months Boosts Stock:** {three*2}\n\n**1 Month Tokens Stock:** {one}\n**1 Month Boosts Stock:** {one*2}",
color=0x4598d2
)

await ctx.respond(embed=embed)

@bot.slash_command(guild_ids=[config["guildID"]], name="boost", description="Boosts a discord server.")
async def boost(ctx, invite: str, amount: int, months: int, nick: str = config['server_nick']):
if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**", description="You must be an owner or an administrator to use this command!", color=0xc80000))

if months not in (1, 3):
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**", description="Months can either be 3 (months) or 1 (month).", color=0xc80000))

if amount % 2 != 0:
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**", description="Amount needs to be even", color=0xc80000))

if months == 1:
filename = "input/1m_tokens.txt"
elif months == 3:
filename = "input/3m_tokens.txt"

if checkEmpty(filename):
return await ctx.respond(embed=discord.Embed(title="**Stock Error**", description="There is currently no stock in the files. Please use /restock to add nitro tokens to the stock files.", color=0xc80000))

if len(open(filename, "r").readlines()) < amount / 2:
return await ctx.respond(embed=discord.Embed(title="**Stock Error**", description="There is currently not enough stock in the files. Please use /restock to add nitro tokens to the stock files.", color=0xc80000))

invite = getinviteCode(invite)

if not validateInvite(invite):
return await ctx.respond(embed=discord.Embed(title="**Invite Error**", description="The invite submitted is invalid. Please submit a valid invite link.", color=0xc80000))

await ctx.respond(embed=discord.Embed(title="**Boosts Started**", description=f"**Invite Link: **
Bağlantıları görmek için lütfen Giriş Yap
{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months", color=0x4598d2))

print()
print(f"Boosting
Bağlantıları görmek için lütfen Giriş Yap
{invite}, {amount} times for {months} months", True)
start = time.time()
boosted = thread_boost(invite, amount, months, nick)
end = time.time()
time_taken = round(end - start, 2)

if not boosted:
with open('success.txt', 'w') as f:
for line in variables.success_tokens:
f.write(f"{line}\n")

with open('failed.txt', 'w') as g:
for line in variables.failed_tokens:
g.write(f"{line}\n")

embed2 = DiscordEmbed(
title="**Boosts Unsuccessful**",
description=f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **
Bağlantıları görmek için lütfen Giriş Yap
{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}",
color='c80000'
)
embed2.set_timestamp()
webhook = DiscordWebhook(url=config["boost_failed_log_webhook"])
webhook.add_embed(embed2)
webhook.execute()
print()
print(
f"Failed to Boost
Bağlantıları görmek için lütfen Giriş Yap
{invite}, {amount} times for {months} months. Operation took {time_taken} seconds", False)
print()

webhook = DiscordWebhook(url=config["boost_failed_log_webhook"])
with open("success.txt", "rb") as f:
webhook.add_file(file=f.read(), filename='success.txt')
with open("failed.txt", "rb") as f:
webhook.add_file(file=f.read(), filename='failed.txt')
webhook.execute()

os.remove("success.txt")
os.remove("failed.txt")

return await ctx.respond(embed=discord.Embed(title="**Boosts Unsuccessful**", description=f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **
Bağlantıları görmek için lütfen Giriş Yap
{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}", color=0xc80000))

elif boosted:
with open('success.txt', 'w') as f:
for line in variables.success_tokens:
f.write(f"{line}\n")

with open('failed.txt', 'w') as g:
for line in variables.failed_tokens:
g.write(f"{line}\n")

embed3 = DiscordEmbed(
title="**Boosts Successful**",
description=f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **
Bağlantıları görmek için lütfen Giriş Yap
{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}",
color='4598d2'
)
embed3.set_timestamp()
webhook = DiscordWebhook(url=config["boost_log_webhook"])
webhook.add_embed(embed3)
webhook.execute()
print()
print(
f"Boosted
Bağlantıları görmek için lütfen Giriş Yap
{invite}, {amount} times for {months} months. Operation took {time_taken} seconds", True)
print()

webhook = DiscordWebhook(url=config["boost_log_webhook"])
with open("success.txt", "rb") as f:
webhook.add_file(file=f.read(), filename='success.txt')
with open("failed.txt", "rb") as f:
webhook.add_file(file=f.read(), filename='failed.txt')
webhook.execute()

os.remove("success.txt")
os.remove("failed.txt")

return await ctx.respond(embed=discord.Embed(title="**Boosts Successful**", description=f"**Boost Type: **Manual\n**Order ID: **N/A\n**Product Name: **{amount} Server Boosts [{months} Months]\n**Customer Email: **N/A\n\n**Invite Link: **
Bağlantıları görmek için lütfen Giriş Yap
{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months\n\n**Time Taken: **{time_taken} seconds\n**Successful Tokens: **{len(variables.success_tokens)}\n**Successful Boosts: **{len(variables.success_tokens)*2}\n\n**Failed Tokens: **{len(variables.failed_tokens)}\n**Failed Boosts: **{len(variables.failed_tokens)*2}", color=0x4598d2))

clear()
# Add the appropriate code to start your bot here.
 
Seçkin Üye
Katılım
23 Ağu 2022
Mesajlar
303
Tepki puanı
114
Ödüller
3
Sosyal
3 HİZMET YILI
It seems like you're trying to boost a Discord server multiple times for a specified number of months using tokens stored in files. From the provided code, I don't see any obvious issues that would cause the bot to stop after boosting with only one token. However, there might be several potential reasons for this behavior:

Token Availability: Ensure that you have enough tokens available in your token files (1m_tokens.txt and 3m_tokens.txt) for the number of boosts you're attempting. If the bot exhausts all available tokens after boosting once, it won't be able to boost again until you restock the tokens.
import time
from discord.ext import commands
import discord
import os
import json
import requests
from boosting import *
from auto import *
from keep_alive import keep_alive # Assuming keep_alive.py contains your keep_alive function

config = json.load(open("config.json", encoding="utf-8"))

if os.name == "nt":
import ctypes

def clear(): # Clears the terminal
os.system('cls' if os.name == 'nt' else 'clear')


if os.name == "nt":
ctypes.windll.kernel32.SetConsoleTitleW("Boost Bot")

activity = discord.Activity(type=discord.ActivityType.watching, name=config["bot_status"])
bot = commands.Bot(command_prefix=">", intents=discord.Intents.all(), activity=activity)


@bot.event
async def on_ready():
print(f"{bot.user} is online!")


@bot.slash_command(guild_ids=[config["guildID"]], name="ping", description="Check the bot's latency.")
async def ping(ctx):
await ctx.respond(embed=discord.Embed(title="**Pong!**", description=f"{round(bot.latency * 1000)} ms",
color=0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="restock",
description="Allows one to restock 1 month or 3 month nitro tokens.")
async def restock(ctx, code: discord.Option(str, "Paste.ee link", required=True),
type: discord.Option(int, "Type of tokens you are restocking, 3 months or 1 month",
required=True)):
if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**",
description="You must be an owner or an administrator to use this command!",
color=0xc80000))
if type != 1 and type != 3 and type != 0:
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**",
description="Type can either be 3 (months), 1 (month) or empty",
color=0xc80000))
if type == 1:
file = "input/1m_tokens.txt"
elif type == 3:
file = "input/3m_tokens.txt"

code = code.replace("
Bağlantıları görmek için lütfen Giriş Yap
", "")
temp_stock = requests.get(f"
Bağlantıları görmek için lütfen Giriş Yap
{code}",
headers={"User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36"}).text
fingerprint_modification()

with open(file, "a", encoding="utf-8") as f:
f.write(f"{temp_stock}\n")
lst = temp_stock.split("\n")
await ctx.respond(embed=discord.Embed(title="**Success**",
description=f"Successfully added {len(lst)} tokens to {file}",
color=0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="addowner",
description="Adds an owner.")
async def addowner(ctx, member: discord.Option(discord.Member, "Member who has add to be added as an owner.",
required=True)):
if ctx.author.id not in config["ownerID"]:
return await ctx.respond(embed=discord.Embed(title="**Missing Permissionn**",
description="You must be an owner to use this command!",
color=0xc80000))

config["ownerID"].append(member.id)
with open('config.json', 'w') as f:
json.dump(config, f, indent=4)

await ctx.respond(embed=discord.Embed(title="**Success**",
description=f"Successfully added {member} ({member.id}) as an owner.",
color=0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="addadmin",
description="Adds an admin.")
async def addadmin(ctx, member: discord.Option(discord.Member, "Member who has add to be added as an admin.",
required=True)):
if ctx.author.id not in config["ownerID"]:
return await ctx.respond(embed=discord.Embed(title="**Missing Permissionn**",
description="You must be an owner to use this command!",
color=0xc80000))

config["adminID"].append(member.id)
with open('config.json', 'w') as f:
json.dump(config, f, indent=4)

await ctx.respond(embed=discord.Embed(title="**Success**",
description=f"Successfully added {member} ({member.id}) as an owner.",
color=0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="stock", description="Allows you to see the current stock.")
async def stock(ctx):
three = len(open("input/3m_tokens.txt", "r").readlines())
one = len(open("input/1m_tokens.txt", "r").readlines())
await ctx.respond(embed=discord.Embed(title="**Stock**",
description=f"**3 Months Tokens Stock:** {three}\n**3 Months Boosts Stock:** {three * 2}\n\n**1 Month Tokens Stock:** {one}\n**1 Month Boosts Stock:** {one * 2}",
color=0x4598d2))


@bot.slash_command(guild_ids=[config["guildID"]], name="boost", description="Boosts a discord server.")
async def boost(ctx, invite: discord.Option(str, "Invite link to the server you want to boost.", required=True),
amount: discord.Option(int, "Number of times you want to boost the sever.", required=True),
months: discord.Option(int, "Number of months you want to boost the server for 1 or 3.", required=True),
nick: discord.Option(str, "Nickname you want to set for the boosting account.", required=False) = config[
'server_nick']):
if ctx.author.id not in config["ownerID"] and ctx.author.id not in config['adminID']:
return await ctx.respond(embed=discord.Embed(title="**Missing Permission**",
description="You must be an owner or an administrator to use this command!",
color=0xc80000))
if months != 1 and months != 3:
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**",
description="Months can either be 3 (months) or 1 (month).",
color=0xc80000))
if amount % 2 != 0:
return await ctx.respond(embed=discord.Embed(title="**Invalid Input**",
description="Amount needs to be even",
color=0xc80000))
if months == 1:
filename = "input/1m_tokens.txt"
if months == 3:
filename = "input/3m_tokens.txt"

if checkEmpty(filename):
return await ctx.respond(embed=discord.Embed(title="**Stock Error**",
description="There is currently no stock in the files. Please use /restock to add nitro tokens in the stock files.",
color=0xc80000))
if len(open(filename, "r").readlines()) < amount / 2:
return await ctx.respond(embed=discord.Embed(title="**Stock Error**",
description="There is currently not enough stock in the files. Please use /restock to add nitro tokens in the stock files.",
color=0xc80000))

invite = getinviteCode(invite)

if not validateInvite(invite):
return await ctx.respond(embed=discord.Embed(title="**Invite Error**",
description="The invite submitted is invalid. Please submit a valid invite link.",
color=0xc80000))

await ctx.respond(embed=discord.Embed(title="**Boosts Started**",
description=f"**Invite Link: **
Bağlantıları görmek için lütfen Giriş Yap
{invite}\n**Amount: **{amount} Boosts\n**Months: **{months} Months",
color=0x4598d2))

print(f"Boosting
Bağlantıları görmek için lütfen Giriş Yap
{invite}, {amount} times for {months} months")
start = time.time()
boosted = thread_boost(invite, amount, months, nick)
end = time.time()
time_taken = round(end - start, 2)

if not boosted:
await ctx.respond(embed=discord.Embed(title="**Boosts Unsuccessful**",
description=f"Boosting {amount} times for {months} months was unsuccessful.",
color=0xc80000))
print(
f"Failed to Boost
Bağlantıları görmek için lütfen Giriş Yap
{invite}, {amount} times for {months} months. Operation took {time_taken} seconds")
else:
await ctx.respond(embed=discord.Embed(title="**Boosts Successful**",
description=f"Boosting {amount} times for {months} months was successful.",
color=0x4598d2))
print(
f"Boosted
Bağlantıları görmek için lütfen Giriş Yap
{invite}, {amount} times for {months} months. Operation took {time_taken} seconds")


keep_alive()
bot.run(config['bot_token'])
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst