Category : discord.py

I am making a discord bot with python. However, the on_message_join function doesn’t seem to work. This is my code: import discord client = discord.Client() @client.event async def on_member_join(member): print("test") client.run(‘token’) When a member joins it doesn’t print "test". Does anyone know how to fix this? Source: Python..

Read more

Im making a leaderboard for my discord server. Here is the code: scores_tuples = [] for member in ctx.guild.members: name, score = member.name.split()[0], len(member.roles)-1 scores_tuples.append((name,score)) scores_tuples.sort(key=lambda t: t[1], reverse=True) for i, (name, score) in enumerate(scores_tuples[:3]): await ctx.send(f"★ {name} {score}") I want to make the top 3 scores to have a star next to them and ..

Read more

Okay so im making a verify system on my server, but im stuck with it. Intents are enabled, in the code and in the dev portal too. i ran a debugger too, but it found nothing. Code: @commands.Cog.listener() async def on_member_join(member): role = discord.utils.get(member.guild.roles, name="Unverified") await member.add_roles(role) channel = discord.utils.get(member.guild.channels, name="welcome") embed = discord.Embed(title=f"Welcome {member}", ..

Read more

Hello everyone so i am new to discord.py and i want to make a leaderboard command guildwise and here is my code import json import discord from tabulate import tabulate from discord.ext import commands from PIL import Image, ImageFont, ImageDraw class ChatLeaderboard(commands.Cog): def __init__(self, bot): self.bot = bot @commands.Cog.listener() async def on_message(self, message): if not ..

Read more

code: url2 =(‘http://ddragon.leagueoflegends.com/cdn/12.1.1/data/en_US/champion.json’) response2 = urlopen(url2) data_json2 = json.loads(response2.read()) if message.content.startswith(‘$api ‘): playersum = (message.content.split(‘$api ‘)[1]) champ_dict = {} for key in data_json2[‘data’]: row = data_json2[‘data’][key] champ_dict[row[‘key’]] = row[‘id’] print(str(champ_dict[row[’44’]])) >>> Ignoring exception in on_message Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 260, in on_message ..

Read more

So I have this command that gives you information on a user. Problem is, I get an error when I use the command on another person. For example, -userinfo (gives you information on yourself) works perfectly, however, when I use -userinfo @User1(gives you information on another person) it will not give me their information. Error: ..

Read more