so I have an bot, written and based on Discord.py, and I am encountering an very strange issue, I have my bot hosted on CentOs 6, 64 bit, and installed with python 3.6.3. I am starting the bot through cd'ing it to the main folder and use python3.6 main.py. See this code snippet:
@bot.command(aliases=["pokemon", "Pokemon", "POKEMON", "PoGo", "POGO", "PokeMonGo", "Pokémon GO"], pass_context=True)
async def pokemongo(ctx):
gotrole = discord.utils.get(ctx.message.server.roles, name="1")
pogorole = discord.utils.get(ctx.message.server.roles, name="Pokémon GO")
if gotrole in ctx.message.author.roles:
await bot.say("You already have a role! Contact support if you want to change!")
return
else:
await bot.add_roles(ctx.message.author, pogorole)
time.sleep(2)
await bot.add_roles(ctx.message.author, gotrole)
await bot.say("Got you the role, Pokémon GO!")
That should totally work, what happens is that the user gets the role Pokemon GO and then the role 1, and then weirdly, the role Pokemon GO gets deleted, sometimes it does happens, sometimes it doesn't, and it's nothing to do with roles, permissions, the code between or below. This snippet is used for various other roles too, using the same template just differing in the commands name (async def) and the roles variable (pogorole in this case)
The weird part its completely random, and actually done by the bot, and not someone else, see the imported libraries below
import discord
from discord.ext import commands
from discord.utils import get
import os
import random
import sys
import asyncio
import aiohttp
import time
import psutil
And an other example of another snippet of code, using the same template:
@bot.command(pass_context=True)
async def fortnite(ctx):
gotrole = discord.utils.get(ctx.message.server.roles, name="1")
fortniterole = discord.utils.get(ctx.message.server.roles, name="Fortnite")
if gotrole in ctx.message.author.roles:
await bot.say("You already have a role! Contact support if you want to change!")
return
else:
await bot.add_roles(ctx.message.author, fortniterole)
time.sleep(2)
await bot.add_roles(ctx.message.author, gotrole)
await bot.say("Got you the role, fortnite!")
It does not error out and the role 1 does not change or gets removed from the user, its just the game role that randomly does, it doesn't have anything to do with internet or something similiar I really hope there is an explanation to this, and would really love to hear some!
Cheers, Deadly