示例#1
0
 async def on_ready(self):
     print('logged in as')
     print(self.user)
     print(self.user.id)
     await self.change_presence(activity=discord.Activity(
         type=discord.ActivityType.watching, name='you all'))
示例#2
0
async def default():
    await client.wait_until_ready()
    await client.change_presence(activity=discord.Activity(
        type=discord.ActivityType.watching, name='.help'))
import random
import discord
from discord.ext import commands
import config

TOKEN = config.TOKEN
intents = discord.Intents.all()

bot = commands.Bot(command_prefix=commands.when_mentioned_or('?'), activity=discord.Activity(name='this server', type=discord.ActivityType.watching), intents=intents)

@bot.command(aliases=['random'])
@commands.guild_only()
async def randomise(ctx):
    """Randomly pairs up all members on the server"""
    members = [member for member in ctx.guild.members if not member.bot]
    if not members:
        return await ctx.send("Please enable privileged intents from the Discord developer portal")
    random.shuffle(members)
    lone = None
    if len(members) % 2 == 1:
        lone = members.pop()
    pairs = []
    while members:
        pairs.append((members.pop(), members.pop())
    text = '\n'.join([f"{num}. {pair[0].mention}, {pair[1].mention}" for num, pair in enumerate(pairs, 1)])
    if lone:
        text += f'\n\nLone: {lone}'
    await ctx.send(f"Randomised all server members into pairs:\n{text}")
                     
@bot.command()
async def ping(ctx):
示例#4
0
import datetime
from datetime import timedelta, tzinfo, timezone
import random
import json
from discord.activity import Spotify
import sys
import traceback
from bs4 import BeautifulSoup
import requests
import lxml
from lyrics_extractor import SongLyrics

# Setup & Variables

client = commands.Bot(command_prefix=PREFIX_HERE)
activity = discord.Activity(name='the death calendar.', type=discord.ActivityType.watching)
client.remove_command('help')
launchtime = datetime.datetime.utcnow()
#
botVersion = BOT_VERSION_HERE
botAuthor = YOUR_TAG_HERE
#
owner_id = YOUR_ID_HERE
guild_id = MAIN_GUILD_ID_HERE
yes = POSITIVE_EMOJI_MENTION_HERE
no = NEGATIVE_EMOJI_MENTION_HERE
#
footer = 'ReaperBot ©2020 | r?help'
footer2 = 'ReaperBot ©2020'
#
responses = ['It is certain.', 'It is decidedly so.', 'Without a doubt.', 'Definately', 'You may rely on it.', 'Most likely.', 'Looks good.', 'Yes.', 'Signs point to yes.', 'Hazy. Try again.', 'Ask again later.', 'It is best to not answer right away.', 'Cannot predict that right now.', 'Concentrate, then ask again.', "Don't count on it.", 'No.', 'Doubtful.', 'My source says no.', "The outlook ain't so good."]
示例#5
0
async def on_ready():
    time.sleep(1)
    print('Connected to Discord!')
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing,name='/h for help'))
示例#6
0
async def on_ready():
    activity = discord.Activity(name="Suspicious People", type=3)
    await client.change_presence(status=discord.Status.online,
                                 activity=activity)
    print("The Bot is ready!")
示例#7
0
async def on_ready():
    await client.change_presence(activity=discord.Activity(
        type=discord.ActivityType.watching, name="your order ids"))
    print('License Bot - READY !')
示例#8
0
async def on_ready():
    await client.change_presence(activity=discord.Activity(
        type=discord.ActivityType.watching, name="$help"))
    print('We have logged in as {0.user}'.format(client))
示例#9
0
async def on_guild_remove(guild):
    await bot.change_presence(status=discord.Status.dnd,
                              activity=discord.Activity(
                                  type=discord.ActivityType.watching,
                                  name=f"{len(bot.users)} Users | x!help"))
    print("LEFT Server")
示例#10
0
文件: main.py 项目: akeeme/quantalbot
 async def on_ready(self):
     await client.change_presence(status=discord.Status.online,
                                  activity=discord.Activity(
                                      type=discord.ActivityType.watching,
                                      name="the Stock Market"))
     print('Logged in as', client.user.name)
示例#11
0
 async def on_connect(self):
     presence = "to your commands. Use -help for more information."
     await self.bot.change_presence(activity=discord.Activity(
         type=discord.ActivityType.listening, name=presence))
示例#12
0
async def on_ready():
    print("I'm ready to go!")
    print(bot.user.name)
    print(bot.user.id)
    await bot.change_presence(activity = discord.Activity(type = discord.ActivityType.watching, name= 'people swearing'))
示例#13
0
 async def on_ready(self):
     print('Bot is online.')
     await self.client.change_presence(
         status=discord.Status.dnd,
         activity=discord.Activity(type=discord.ActivityType.listening,
                                   name=(f"How Webhooks Work | w.help")))
示例#14
0
 async def status():
     while True:
         await self.bot.wait_until_ready()
         await self.bot.change_presence(status=discord.Status.do_not_disturb ,activity=discord.Activity(type=discord.ActivityType.watching, name='-Help | Use -Invite to invite Mecha Karen 👀'))
         await sleep(10)
         await self.bot.change_presence(status=discord.Status.do_not_disturb ,activity=discord.Activity(type=discord.ActivityType.listening, name=f'{len(self.bot.commands)} Commands | {len(self.bot.users)} Users | {len(self.bot.guilds)} Servers'))
         await sleep(10)
         await self.bot.change_presence(status=discord.Status.do_not_disturb ,activity=discord.Activity(type=discord.ActivityType.watching, name=f"My next updates."))
         await sleep(10)
         await self.bot.change_presence(status=discord.Status.do_not_disturb ,activity=discord.Activity(type=discord.ActivityType.listening, name='the Manager!'))
         await sleep(10)
         await self.bot.change_presence(status=discord.Status.do_not_disturb ,activity=discord.Activity(type=discord.ActivityType.playing, name='Use -Source to view the source code!'))
         await sleep(10)
示例#15
0
async def status(ctx, *, tempgame=None):
    # Changes the bot's status. By default, it is limited to the owner only
    if ctx.author.id == myid:
        await bot.change_presence(status=discord.Status.idle,
                                  activity=discord.Activity(
                                      type=typeStatusListen, name=tempgame))
示例#16
0
async def on_member_remove(member):
    await bot.change_presence(status=discord.Status.dnd,
                              activity=discord.Activity(
                                  type=discord.ActivityType.watching,
                                  name=f"{len(bot.users)} Users | x!help"))
    print(f"MEMBER Left Server ({member.guild.id} - {member.id}")
示例#17
0
import aiohttp, asyncio, discord, random
from classes.enums import difficulties, categories
from MiniUtils import minidiscord, data, classes

with open('token.txt') as f:
    token = [line.strip() for line in f]

bot = minidiscord.Bot(
    command_prefix='=',
    case_insensitive=True,
    owner_ids=[
        317731855317336067, 438733159748599813, 261900651230003201,
        421698654189912064
    ],
    activity=discord.Activity(
        name="questions get answered.", type=discord.ActivityType.watching
    ),  # We create a discord activity to start up with
    status=discord.Status.dnd)


async def get_cards(
        amount,
        difficulty: difficulties.Difficulty = difficulties.Difficulty.ALL,
        category: categories.Category = categories.Category.ALL):
    async with aiohttp.ClientSession() as session:
        async with session.get(
                f'https://opentdb.com/api.php?amount={amount}{difficulty.value}{category.value}&type=multiple'
        ) as resp:
            if resp.status == 200:
                response = await resp.json()
                if response['response_code'] == 0:
示例#18
0
async def on_ready():
    print("ready!")
    await client.change_presence(
        activity=discord.Activity(name="joins", type=2))
示例#19
0
async def change_status():
    await client.change_presence(
        activity=discord.Activity(type=discord.ActivityType.listening,
                                  name=list_of_status[random.randint(0, 10)]))
示例#20
0
async def on_ready():
    print('Connected to Discord')
    await discord_client.change_presence(activity=discord.Activity(
        name="the candlesticks", type=discord.ActivityType.watching))
示例#21
0
async def on_ready():
    print("Ready for action!")
    await client.change_presence(activity = discord.Activity(
        name = "fruit expire",
        type = discord.ActivityType.watching)
    )
示例#22
0
async def on_ready():
    print(f'{bot.user.name} has connected to Discord!')
    return await bot.change_presence(
        activity=discord.Activity(type=1, name="Hoarding artifacts"))
示例#23
0
    async def game(self, ctx, *, game: str = None):
        """Set game/stream. Ex: [p]game napping [p]help game for more info

        Your game/stream status will not show for yourself, only other people can see it. This is a limitation of how the client works and how the api interacts with the client.

        --Setting playing/watching/listening--
        Set a game: [p]game <text>
        Set watching: [p]watching <text>
        Set listening: [p]listening <text>
        To set a rotating game status, do [p]game game1 | game2 | game3 | etc.
        It will then prompt you with an interval in seconds to wait before changing the game and after that the order in which to change (in order or random)
        Ex: [p]game with matches | sleeping | watching anime

        --Setting stream--
        Same as above but you also need a link to the stream. (must be a valid link to a stream or else the status will not show as streaming).
        Add the link like so: <words>=<link>
        Ex: [p]stream Underwatch=https://www.twitch.tv/a_seagull
        or [p]stream Some moba=https://www.twitch.tv/doublelift | Underwatch=https://www.twitch.tv/a_seagull"""
        is_stream = False
        if ctx.invoked_with == "game":
            message = "Playing"
            self.bot.status_type = discord.ActivityType.playing
        elif ctx.invoked_with == "stream":
            is_stream = True
            self.bot.status_type = discord.ActivityType.streaming
            self.bot.is_stream = True
        elif ctx.invoked_with == "watching":
            message = "Watching"
            self.bot.status_type = discord.ActivityType.watching
        elif ctx.invoked_with == "listening":
            message = "Listening to"
            self.bot.status_type = discord.ActivityType.listening
        if game:
            # Cycle games if more than one game is given.
            if ' | ' in game:
                await ctx.send(
                    self.bot.bot_prefix +
                    'Input interval in seconds to wait before changing (``n`` to cancel):'
                )

                def check(msg):
                    return (msg.content.isdigit()
                            or msg.content.lower().strip()
                            == 'n') and msg.author == self.bot.user

                def check2(msg):
                    return (msg.content == 'random'
                            or msg.content.lower().strip() == 'r'
                            or msg.content.lower().strip() == 'order'
                            or msg.content.lower().strip()
                            == 'o') and msg.author == self.bot.user

                reply = await self.bot.wait_for("message", check=check)
                if not reply:
                    return
                if reply.content.lower().strip() == 'n':
                    return await ctx.send(self.bot.bot_prefix + 'Cancelled')
                elif reply.content.strip().isdigit():
                    interval = int(reply.content.strip())
                    if interval >= 10:
                        self.bot.game_interval = interval
                        games = game.split(' | ')
                        if len(games) != 2:
                            await ctx.send(
                                self.bot.bot_prefix +
                                'Change in order or randomly? Input ``o`` for order or ``r`` for random:'
                            )
                            s = await self.bot.wait_for("message",
                                                        check=check2)
                            if not s:
                                return
                            if s.content.strip() == 'r' or s.content.strip(
                            ) == 'random':
                                await ctx.send(
                                    self.bot.bot_prefix +
                                    '{status} set. {status} will randomly change every ``{time}`` seconds'
                                    .format(status=message,
                                            time=reply.content.strip()))
                                loop_type = 'random'
                            else:
                                loop_type = 'ordered'
                        else:
                            loop_type = 'ordered'

                        if loop_type == 'ordered':
                            await ctx.send(
                                self.bot.bot_prefix +
                                '{status} set. {status} will change every ``{time}`` seconds'
                                .format(status=message,
                                        time=reply.content.strip()))

                        stream = 'yes' if is_stream else 'no'
                        games = {
                            'games': game.split(' | '),
                            'interval': interval,
                            'type': loop_type,
                            'stream': stream,
                            'status': self.bot.status_type
                        }
                        with open('settings/games.json', 'w') as g:
                            json.dump(games, g, indent=4)

                        self.bot.game = game.split(' | ')[0]

                    else:
                        return await ctx.send(
                            self.bot.bot_prefix +
                            'Cancelled. Interval is too short. Must be at least 10 seconds.'
                        )

            # Set game if only one game is given.
            else:
                self.bot.game_interval = None
                self.bot.game = game
                stream = 'yes' if is_stream else 'no'
                games = {
                    'games': str(self.bot.game),
                    'interval': '0',
                    'type': 'none',
                    'stream': stream,
                    'status': self.bot.status_type
                }
                with open('settings/games.json', 'w') as g:
                    json.dump(games, g, indent=4)
                if is_stream and '=' in game:
                    g, url = game.split('=')
                    await ctx.send(self.bot.bot_prefix +
                                   'Stream set as: ``Streaming %s``' % g)
                    await self.bot.change_presence(
                        activity=discord.Streaming(name=g, url=url))
                else:
                    await ctx.send(
                        self.bot.bot_prefix +
                        'Game set as: ``{} {}``'.format(message, game))
                    await self.bot.change_presence(activity=discord.Activity(
                        name=game, type=self.bot.status_type))

        # Remove game status.
        else:
            self.bot.game_interval = None
            self.bot.game = None
            self.bot.is_stream = False
            await self.bot.change_presence(activity=None)
            await ctx.send(self.bot.bot_prefix + 'Set playing status off')
            if os.path.isfile('settings/games.json'):
                os.remove('settings/games.json')
示例#24
0
    def __init__(self, **kwargs):
        super().__init__(
            command_prefix=get_prefix,
            case_insensitive=True,
            # case_insensitive_prefix=True,
            status=discord.Status.dnd,
            activity=discord.Activity(type=discord.ActivityType.competing,
                                      name='a boot up challenge'),
            owner_id=345457928972533773,
            reconnect=True,
            allowed_mentions=discord.AllowedMentions(users=False,
                                                     roles=False,
                                                     everyone=False,
                                                     replied_user=True),
            max_messages=10000,
            chunk_guilds_at_startup=
            True,  # this is here for easy access. In case I need to switch it fast to False I won't need to look at docs.
            intents=discord.Intents(
                guilds=True,  # guild/channel join/remove/update
                members=True,  # member join/remove/update
                bans=True,  # member ban/unban
                emojis=False,  # emoji update
                integrations=False,  # integrations update
                webhooks=False,  # webhook update
                invites=False,  # invite create/delete
                voice_states=True,  # voice state update
                presences=False,  # member/user update for games/activities
                guild_messages=True,  # message create/update/delete
                dm_messages=True,  # message create/update/delete
                guild_reactions=True,  # reaction add/remove/clear
                dm_reactions=True,  # reaction add/remove/clear
                guild_typing=False,  # on typing
                dm_typing=False,  # on typing
            ))

        self.config = config

        for extension in config.EXTENSIONS:
            try:
                self.load_extension(extension)
                print(f'[EXTENSION] {extension} was loaded successfully!')
            except Exception as e:
                print(f'[WARNING] Could not load extension {extension}: {e}')

        self.db = kwargs.pop("db")
        self.cmdUsage = {}
        self.cmdUsers = {}
        self.guildUsage = {}
        self.process = psutil.Process()

        self.support = 'https://discord.gg/f3MaASW'
        self.invite = 'https://dredd-bot.xyz/invite'
        self.privacy = 'https://dredd-bot.xyz/privacy-policy'
        self.license = '<https://github.com/TheMoksej/Dredd/blob/master/LICENSE>'
        self.gif_pfp = 'https://cdn.discordapp.com/attachments/667077166789558288/747132112099868773/normal_3.gif'
        self.vote = '<https://discord.boats/bot/667117267405766696/vote>'
        self.source = '<https://github.com/TheMoksej/Dredd/>'
        self.statuspage = '<https://status.dredd-bot.xyz>'
        self.bot_lists = {
            'dbots':
            "[Discord Bot Labs](https://dbots.cc/dredd 'bots.discordlabs.org')",
            'dboats':
            "[Discord Boats](https://discord.boats/bot/667117267405766696/vote 'discord.boats')",
            'dbl':
            "[Discord Bot list](https://discord.ly/dredd/upvote 'discordbotlist.com')",
            'shitgg':
            "[Top.GG](https://top.gg/bot/667117267405766696/vote 'top.gg')"
        }
        self.cleverbot = ac.Cleverbot(config.CB_TOKEN)
        self.join_counter = Counter(
        )  # counter for anti raid so the bot would ban the user if they try to join more than 5 times in short time span
        self.counter = Counter()  # Counter for global commands cooldown

        self.cache = CacheManager
        self.cmd_edits = {}
        self.dm = {}
        self.dms = {
        }  # cache for checks if user was already informed about dm logging
        self.updates = {}
        self.snipes = {}
        self.sr_api = sr_api.Client()

        self.guilds_data = {}
        self.loop = asyncio.get_event_loop()
        self.guild_loop = {}
        self.to_dispatch = {}
        self.music_guilds = {}

        # ranks
        self.devs = {}
        self.admins = {}
        self.boosters = {}
        self.lockdown = False
        self.auto_reply = True
        self.settings = {}
        self.blacklist = {}
        self.check_duration = {}

        # guilds / moderation
        self.prefix = {}
        self.moderation = {}
        self.memberlog = {}
        self.joinlog = {}
        self.leavelog = {}
        self.guildlog = {}
        self.joinrole = {}
        self.joinmessage = {}
        self.leavemessage = {}
        self.messageedits = {}
        self.messagedeletes = {}
        self.antihoist = {}
        self.automod = {}
        self.massmention = {}
        self.masscaps = {}
        self.invites = {}
        self.links = {}
        self.spam = {}
        self.modlog = {}
        self.raidmode = {}
        self.temp_bans = {}
        self.temp_mutes = {}
        self.mutes = {}
        self.bans = {}
        self.mute_role = {}
        self.mod_role = {}
        self.admin_role = {}
        self.channels_whitelist = {}
        self.roles_whitelist = {}
        self.guild_disabled = {}
        self.cog_disabled = {}
        self.case_num = {}
        self.rr = {}

        # other
        self.afk = {}
        self.status_op = {}
        self.snipes_op = {}
        self.nicks_op = {}
        self.badges = {}
        self.disabled_commands = {}
        self.translations = {}
        self.reminders = {}
示例#25
0
        self.start_time = time.time()
        self.main_guild = self.get_guild(self.config['bot']['main_guild'])
        self.supporter_role = self.main_guild.get_role(
            self.config['bot']['supporter_role'])
        if self.supporter_role:
            for user in self.supporter_role.members:
                self.supporters.add(user.id)

        if game := self.state.get('game', None):
            activity = discord.Game(game)
        elif song := self.state.get('song', None):
            activity = discord.Activity(name=song,
                                        type=discord.ActivityType.listening)
        else:
            activity = discord.Activity(name='your problems',
                                        type=discord.ActivityType.listening)

        await self.change_presence(activity=activity)

    def is_admin(self, user: discord.Member):
        if user.id in self.admins:
            return True
        return False

    def is_supporter(self, user: discord.Member):
        if self.is_admin(user):
            return True
        elif user.id in self.supporters:
            return True
        return False
示例#26
0
 async def on_ready(self):
     activity = discord.Activity(type=discord.ActivityType.watching, name="you write code")
     await bot.change_presence(activity=activity)
示例#27
0
 async def set_listening_status(self, song_name):
     await self.bot.change_presence(activity=discord.Activity(
         type=discord.ActivityType.listening, name=song_name))
示例#28
0
async def on_ready():
    print('Logged in as', bot.user)
    activity = discord.Activity(name='DiscordVoIP by zelek#6666', type=discord.ActivityType.watching)
    await bot.change_presence(activity=activity)
示例#29
0
async def game(ctx, game):
    await bot.change_presence(
        activity=discord.Activity(type=discord.ActivityType.playing, name=game)
    )
示例#30
0
 async def on_ready():
     print(f'{bot.user} has connected to Discord!')
     print('running ping role task')
     next_match_ping.start()
     await bot.change_presence(activity=discord.Activity(
         type=discord.ActivityType.listening, name="!chelp for commands"))