import os import time import json import discord from dotenv import load_dotenv from discord.ext import commands def checkEnv(): print('Checking if token.env exists...') try: out_file = open('token.env') print('Token is ready!') except IOError: print('First you have to give us the Discord Token for your bot!') token = input('token: ') out_file = open('token.env', 'w') out_file.write(f'DISCORD_TOKEN={token}') finally: out_file.close() pass checkEnv() load_dotenv("token.env") TOKEN = os.getenv('DISCORD_TOKEN') # GUILD = os.getenv('DISCORD_GUILD') # ZENEID = os.getenv('ZENEKOMMAND_ID') # YEPID = os.getenv('YEP_ID') client = commands.Bot(command_prefix='$') @client.command() async def setmusicroom(ctx, arg): server = ctx.guild channel = discord.utils.get(server.channels, name=arg) channelid = channel.id file = open('setup.env', 'w') file.write(f'MUSICCHANNEL={channelid}') file.close() load_dotenv('setup.env') async def help(ctx): await ctx.send('This is the help!') @client.event async def on_message(message): if message.author == client.user: return load_dotenv('setup.env') await client.process_commands(message) server = message.guild channel = discord.utils.get(server.channels, name=message.channel.name) print(channel.id) channel_zene = client.get_channel(int(os.getenv('MUSICCHANNEL'))) # channel_yep = client.get_channel(733950633291546686) # if str(message.author) == 'Rythm#3722': # return print(message.author) if not str(message.author) == 'Rythm#3722': if str(channel_zene) == str(message.channel) and not(message.content.startswith('!')): print(f"{channel_zene} , {message.channel}") await message.channel.send('Kérlek ebbe a szobába csak a Rythm botnak adj parancsokat. Köszönöm!') await message.delete() if message.author == 'Rythm': await message.delete() if str(channel_zene) != str(message.channel) and (message.content.startswith('!')): print(f"{channel_zene} , {message.channel}") await message.channel.send('Ez nem a zene-kommand szoba, ide kérlek ne írj parancsokat a Rythm botnak. Köszönöm!') await message.delete() # if str(channel_yep) == str(message.channel) and message.author == 'Rythm': # message.delete() client.run(TOKEN)