discord.py

How to install discord.py-rewrite dependency on Heroku for Discord bot hosting?

戏子无情 提交于 2021-02-05 10:55:17
问题 I'm trying to deploy my discord.py bot on Heroku using my GitHub master branch, but have been unable to do because of a git error: Could not find a tag or branch 'rewrite', assuming commit . What do I need to do to successfully install the 'rewrite' dependency? I am currently using the files "requirements.txt", "runtime.txt", "Procfile" and "Aptfile". I've tried several combinations of dependencies in my requirements.txt file, including: git+https://github.com/Rapptz/discord.py@rewrite git

Sending message every minute in discord.py

巧了我就是萌 提交于 2021-02-05 09:44:44
问题 I am trying to make the bot send a message every minute in discord.py. I do acknowledge that this is a easy thing to do but I have tried multiple times but resulting with no luck. I have not gotten any error messages. Here is my code: import discord from discord.ext import tasks client = discord.Client() @tasks.loop(minutes=1) async def test(): channel = client.get_channel(CHANNEL_ID) channel.send("test") test.start() client.run(TOKEN) 回答1: You try to get channel with get_channel() , but your

Sending message every minute in discord.py

会有一股神秘感。 提交于 2021-02-05 09:44:07
问题 I am trying to make the bot send a message every minute in discord.py. I do acknowledge that this is a easy thing to do but I have tried multiple times but resulting with no luck. I have not gotten any error messages. Here is my code: import discord from discord.ext import tasks client = discord.Client() @tasks.loop(minutes=1) async def test(): channel = client.get_channel(CHANNEL_ID) channel.send("test") test.start() client.run(TOKEN) 回答1: You try to get channel with get_channel() , but your

Discord.py - change the default help command

最后都变了- 提交于 2021-02-05 08:31:25
问题 I'm trying to change the help command to use a pagination version of help. I understand that the following line of code removes the help command entirely: bot.remove_command('help') The docs/dicord.py server offer the following example as a way to change the default help command: class MyHelpCommand(commands.MinimalHelpCommand): def get_command_signature(self, command): return '{0.clean_prefix}{1.qualified_name} {1.signature}'.format(self, command) class MyCog(commands.Cog): def __init__(self

Python Discord.py `time.sleep()` coroutine

末鹿安然 提交于 2021-02-05 08:09:40
问题 import discord import os import random import time import math client = discord.Client() with open('admins.conf', 'r') as f: for line in f.readlines(): exec(line) with open('bans.conf', 'r') as f: for line in f.readlines(): exec(line) with open('coins.conf', 'r') as f: for line in f.readlines(): exec(line) random.seed(os.urandom(32)) searchusers = [] @client.event async def on_ready(): '''Notification on ready.''' print('Logged in! Bot running.') await client.change_presence(activity=discord

Discord.py bot dont have certificate

落花浮王杯 提交于 2021-02-05 07:56:09
问题 Yesterday I made a bot and everything was working, today when I try to run my code I have this error: ClientConnectorCertificateError(aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1108)')] I am using win10, python 3.8, and pycharm. I saw a similar problem on StackOverflow but the solution Is not working for

NameError: 'discord' is not defined?

别说谁变了你拦得住时间么 提交于 2021-02-05 07:12:05
问题 This is for a discord bot I am making, and I have tried to set the bot's status. I've found an answer that looks like await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for e/info")) and I have put it in an on_ready event function. However, it gives me the following exception: Ignoring exception in on_ready Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312,

discord.py How to set a kick command such that only an administrator can use it?

情到浓时终转凉″ 提交于 2021-02-05 06:12:07
问题 Here is my code - @client.command() @client.command.has_permissions(administrator=True) async def kick(ctx, member: discord.Member): await member.kick() await ctx.message.add_reaction("✅") await ctx.send(f"{member.name} has been kicked by {ctx.author.name}!") await log_channel.send(f"{ctx.author.name} has kicked {member.display_name}") It shows the following the following error - Traceback (most recent call last): File "C:/Users/Gacha/Desktop/Python Bot/bot.py", line 56, in <module> @client

discord.py How to set a kick command such that only an administrator can use it?

拥有回忆 提交于 2021-02-05 06:10:26
问题 Here is my code - @client.command() @client.command.has_permissions(administrator=True) async def kick(ctx, member: discord.Member): await member.kick() await ctx.message.add_reaction("✅") await ctx.send(f"{member.name} has been kicked by {ctx.author.name}!") await log_channel.send(f"{ctx.author.name} has kicked {member.display_name}") It shows the following the following error - Traceback (most recent call last): File "C:/Users/Gacha/Desktop/Python Bot/bot.py", line 56, in <module> @client

discord.py How to set a kick command such that only an administrator can use it?

北战南征 提交于 2021-02-05 06:10:04
问题 Here is my code - @client.command() @client.command.has_permissions(administrator=True) async def kick(ctx, member: discord.Member): await member.kick() await ctx.message.add_reaction("✅") await ctx.send(f"{member.name} has been kicked by {ctx.author.name}!") await log_channel.send(f"{ctx.author.name} has kicked {member.display_name}") It shows the following the following error - Traceback (most recent call last): File "C:/Users/Gacha/Desktop/Python Bot/bot.py", line 56, in <module> @client