GithubHelp home page GithubHelp logo

sharkytheking / sharky Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 9.0 5.5 MB

Sharky's Cogs. If you have any suggestions or issues, please feel free to add them here.

Python 99.54% Makefile 0.15% Batchfile 0.32%
red-discordbot cog discord sharky

sharky's Introduction

Sharky

Codes that I've been working on for use, feedback and issues are welcomed!

Where to find me

Red Cog Support

Install

These codes are for Red Discord Bot, you MUST have a up-todate RedBot to use and/or install these codes.

Charlimit

Limits amount of characters and lines your members are able to send in a channel.

This works perfect for LFG channels that you want to limit the amount of spam they put into their messages.

It'll also send a message saying how many characters / lines is needed to not be removed, though this is defauled to being off. You must turn this on to allow for it to send a message. Currently, not adjustable message.

Note: You MUST have set the proper permissions for the bot to be able to manage_messages in each of the channels affected or else this could cause issues.

Lockdown

Lockdown system for guilds. Let's you completely lockdown your server Text Channels with having the option for the bot to leave a message.

Note: You MUST have set the proper permissions for the bot to be able to send_messages, manage_channels, manage_permissions in each of the channels affected or else this could cause issues.

Commands:

  • Lockdown: Does fullscale lockdown, with asking for permission before doing so.
  • Unlockdown: Does fullscale unlockdown, asks permission before doing so.
  • ChannelLock: Locks down a single channel that you select, Text or Voice channel.
  • ChannelUnlock: Unlocks a single channel that you select.
  • Lockdownset Lockmsg: Gives the bot a message to put in the channels if the Lockdown command is thrown.
  • Lockdownset Unlockmsg: Gives the bot a message to put in channels if the UnLockdown comand is thrown.

MailSystem

Warning: This is a pre-release, this is not close to being completed, I need more feedback and information from Red users. This means that by installing this cog, you understand there is a risk that issues could happen for you, your bot, or the members using your bot.

I am still working on this cog and thinking of ways to handle different things. Currently, this doesn't support restricting modmail to a specific guild. By installing you are allowing every guild owner (or staff that is considered an admin or has manage_channel permissions) the ability to set this up for their guild.

Do not submit random PRs without talking to me or Kreusada, the code is set the way it is for future plans that I won't discuss publicly yet.

Note: These are subject to change at any moment's notice due to the pre-release.

Commands:

  • DmMail: DM command - Starts the process to send a mail ticket to chosen server.

  • StopMail: DM command - Not finished.

  • Mailset: Default command group for Mailsystem Settings

  • Mailset Activate: Sets the system to be enabled or disabled.

    • Must have the category set first, otherwise won't be activated.
  • Mailset Category: Sets the category that channels will be created in.

  • Mailset Commands: Not finished.

  • Mailset Embeds: Not finished.

  • Mailset LogChannel: Sets the logging channel for when a modmail has been created or closed.

  • Mailset ShowSettings: Shows the guild's current settings.

MorseShark

Allows you to encode string into morsecode and lets you decode morsecode into text. Currently only English's standard text is available, if you'd like to help allow for more customizability, please reach out through the red's cog support server.

This is just a simple morse code cog, if you want to take from this cog and use it in your own example, please feel free to.

Note: This can be spammy, as it accounts for users who have 4k character limit.

Commands:

  • Morse: Default command group
  • Morse Encode: Encode a string into morse code.
  • Morse Decode: Decodes morse code text into readable text.

MsgTracker

Counts how many messages a person sends in the guild if enabled. Sorts them into a leaderboard to display, allows for the members to set themselves to be ignored from the bot. Staff members have to allow them to be tracked if the member changes their mind.

Note: As a bot owner, you have the ability to disable the command that sets members to be ignored. This is up to you, though this Cog will still handle data deletions regardless of the command setting.

NameGen

Gives a random name based on first name and last name lists created by you.

Note: There are two functionality. Either sending a message or renaming someone when using the primary command. If you want it to rename, then the bot must need manage_nicknames permission

Commands:

  • NameSet List: Displays your lists of names and settings.
  • NameSet Rename: Toggle system to either rename or send message.
  • NameSet GenMessage: Let's you customize the response when the bot gives/changes name.
  • NameSet Add FirstName: Adds your first names to list.
  • NameSet Add LastName: Adds your last names to list.
  • NameSet Remove FirstName: Removes your first names from list.
  • NameSet Remove LastName: Removes your last names from list.
  • NameGen: Generate a random name and outputs either via text or by changing your name.

NewsPublish

Automatic news publishing for verified / partnered servers that have a news channel.

Note: The bot must have manage_messages and send_messages permissions to publish your messages.

This lets you automatically publish messages via bot, in your news channels. You can set an alert message so the bot will alert the selected channel if it's unable to publish the new message due to Discord's Ratelimit of publishing.

Commands:

  • Addnews: Adds the news channel, checks if the channel is a news channel and checks permissions
  • RemoveNews: Removes the selected channels from listing
  • AlertChannel: Sets the alertchannel to notify if publish failed.

Reports

Report system for Moderators of servers.

Note: The bot must have send_messages and manage_messages permissions or else this could cause issues.

This is a simple report members cog, you set it up and members can report members to the server's moderator without having to have hassles of contacting a moderator directly.

Commands:

  • Report: Reports a member, sends to selected channel in server for moderator's preview.
  • ReportDM: Toggle whether to be DMed when you report.
  • ReportSet Channel: Sets the channel reports goes into.
  • ReportSet Emotes: Sets if the bot automatically adds emotes to the reports sent.

SharkyTools

Tools that I've made for personal use.

Note: If you are to use this, this needs ban_members permissions for the findban command.

Shows members account information (join date, profile picture, etc). Can show specific's users avatar. Find if someone's banned based off of userid.

Commands:

  • Uav: Allows you to preview a user's avatar. (Must be userid)
  • Avatar: Shows member's avatar (Note: Can cause conflict with other cogs for same command)
  • Age: Shows member's age (Join date, account creation, etc)

Verify

Server verification system, requires people to type command to be allowed access in server

Note: This requires your knowledge of locking people out via role. This does not automatically handle this, it assumes you are or the person using this is capable of setting Discord permissions to disallow member viewing any channel except Rules and whatever channel used to send the command in. Due to this, this requires Manage_Roles

sharky's People

Contributors

cool-aid-man avatar jackenmen avatar kreusada avatar madebylydia avatar ryan5453 avatar sharkytheking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sharky's Issues

Add channel filtering

Currently have regular filter, strict filter, whitelist filter. Soon adding channel filtering.

[MailSystem] Guild-User Blocks & Global blocks

Need to rethink how to handle blocks. I'm calling to config a lot for simple things when I could probably store them into a cache system on startups.

Currently, the checks require both a userid and guild object to determine if the user is blocked from the guild.

Global checks are simple since it's a simple list check.

MailSystem Transcripts

Feature Request

What type of feature are you requesting:

  • Cog
  • Command

Describe the feature:

This feature will allow the conversation of a mailsystem ticket to be sent directly to a channel of the users choosing. This is useful for training purposes, transparency, being able to improve for next time, and making sure that the person who was helping is/was doing a good job. This will be for the mailsystem cog.

Link to the transcript feature on a bot

[Lockdown] Alias channellocks

Feature Request

What type of feature are you requesting:

  • Cog
  • Command

Describe the feature:

Alias channellock and unlock to switch around channel and lock. lockchannel, unlockchannel

[MsgTracker] add autorole support

Feature Request

What type of feature are you requesting:

  • Cog
  • [x ] Command

Describe the feature:

Add a command like [p]mtset admin msgrole 100 @100-msg-role which should assign the role to the user upon reaching the 100 messages in the server

Say what cog it's from - MsgTracker
Describe what the command does - Allow auto assigning of roles on reaching a set number of messages.

[MsgTracker] Leaderboard

Daily/Weekly/Monthly leaderboard and a possible top 10 auto-posting to a specific channel.

  • Daily Functionality - Handle DateTime sort proper timeframe of when the daily reset happens
  • Weekly function - Make sure to handle a full week's turn. Possibly start Sunday, ending Sunday.
  • Monthly function - Handle month times
  • Auto posting for weekly needs to handle task set for posting.

Redoing cogs

Plan on merging sharkymod and sharkytools into one.
Fixing up announcement and possibly merge it alongside tools.

[Tools] Sort out tools

Commands needed:

  • Member Avatar (with join dates, account creations)
  • User avatars (simply shows the user's avatar if they're not in the server)
  • Role list (Shows all roles in the server)
  • Members in roles (Lets us show how many people are in said roles, and members tied to role)
    • Possibly export as a CSV/JSON file
    • Or simply do a embed pages w/ pagify

[NewsPublish] Redo settings display

Plan on separating it from publishset command, putting it into it's own command to preview settings.

Will rework how the embed is displayed as well.

Reminder: #60 should be merged first.

[LockDown] Cog redoing

Thanks to @kablekompany for making a PR -> #41

I'll be using this issue to list and detail changes that I'll be making towards Lockdown.

Current list:

  • Account for multiple channel addition/deletion.
  • Remove cross-guild lockdown (not needed, impossible to account for situations and not worth the effort. Discord stability has been reliable enough to not need this for servers)
  • Account for console logging
  • Account for channel notifications.
  • Account for both Text and Voice channels being able to be locked
  • Account for lockdown messages and unlockdown messages not being able to be sent, return message to author saying where they aren't able to be sent.

[MailSystem] Commands or Message

There's a command that lets the bot owner set whether their users have to type a command or simply send a message to the bot's DM to trigger a modmail ticket.

I have yet to handle the on_message portion, this needs to include similar aspects as the [p]dmmail command does. If someone wants to work on this, feel free but please work with us.

[Reports] Fix claim check

Currently it'll add the claim for moderator in the channel the reports are sent to, despite the claim being there or not. This wasn't my intention, need to fix.

[NewsPublish] Don't publish command messages

Feature Request

What type of feature are you requesting:

  • Cog
  • Command
  • An enhancement to an existing cog or command.

Describe the feature:

Use on_message_without_command (or have an option for it) in NewsPublish so it doesn't publish command messages.
Sometimes my server uses [p]embed event in a server in order to announce an upcoming event, but we don't want that command message itself to be announced, only the bot's response.

Also, unrelated, but it's worth noting: Manage Messages is only needed for publishing others' messages. The bot doesn't need that permission to publish its own message.
It may also be worth catching discord.Forbidden in the event itself (or checking for permissions before publishing) in case permissions change in the announcement channel.

[Mailsystem] User Closing

As of right now, there is no way for a user to close their own modmail ticket. This HAS to be done by the staff of the server, which can be a little bit annoying especially since you can only have one modmail ticket active at one time (for a user). So if you wanted to create a modmail for another server but can't because you currently have one active for a different server, you're kind of stuck until the staff closes it.

This needs to handle a few different logic.

  1. Needs to send a message to the current modmail channel saying the user has closed the ticket.
  2. It needs to send logging information to the log channel (assuming the staff has set a log channel).
  3. Allows staff to reapply modmail to the person again if they haven't made another one yet.

[MailSystem] AutoSetup

Create a command that handles automatically setting up the system for a guild.

This needs to be a multistep process that asks the owner (or staff that is considered admin by the bot or has manage_guild's permissions.)

  1. Check if they want to set an already-made category as the mail category.
    • If they choose an already-made category, check permissions for the bot, it MUST need manage_channels permissions.
    • If they want to make a new one, collect what roles they want to have mod access (send messages, manage messages, etc.) and store category in config.
  2. Check if they want to set an already-made logging channel.
    • If they choose to connect to an already-made channel, check permissions for send_message and embed_links, then add to config.
    • If creating a new channel, ask if they want to sync to category perms. If not, get what roles they want access to it.
  3. Asks if they want to use embeds or messages for the new modmail tickets.

If this is worked on before the embed/message configuration is finished, then don't incorporate the third bulletin.

[MailSystem] Handle Attachments

Handle attachments for both Embeds and Message sending.

  • Embeds need to set the image and content
  • Messages can just send as content

One concern is, I don't believe there's a reliable way to send images for transcripts, especially if it's done by the staff team (as you can't delete the message that sent the image or else it'll disappear), so #104 won't be able to handle images.

Inadequate error handling methods

Hi there! I was scrolling through your code when I noticed you're using an if statement rather than a try-except statement.

there are actually two of them that are very useful- commands.BotMissingPermission and
Forbidden.MissingPermissions.

using these, it doesn't matter which permission you don't have- the error will still be thrown and you don't have to worry about handler-proofing your bot with every possible permission that might be denied.

FYI- I'm pretty sure Forbidden.MissingPermission is an HTTPException.

[MailSystem] Closing with time args

Allow for the ability to set a timer to close a channel if it's been inactive (from both staff sending/user sending).

Few ways we could do this.

  1. Check for new contents from the bot that follows given formats.
  2. Dispatch an event every time the command is used/given for the bot to be aware of what channel it's tied to.
  3. That or ignore inactivity and just have timed close option that can only be stopped on the staff's side.

[NewsPublish] Confirmation on publish

New feature to alert / send notification whenever a publish is confirmed. To both make sure the bot is working, keep track of messages being published and help fill in the information.

[NewsPublish] Question

Would it be possible to differentiate self, other bots and users?
So you can for instance have the bot only publish its own messages, self and other bots or just other users.

[MailSystem] Config -> Cache

One of the main issues I knew was going to happen with this cog is a possible memory leak and the large number of config calls that are made.

I've made some attempts to lessen the config calls for the channel checks, though everything else is still calling to config on each command basis.

Need to figure out the best flow for a cache that holds what guild has a user blocked and the global blocks (for guilds and users), along with the other simple config calls.

This CAN'T break the flow of channel checkups, per the following two functions:

    def check_tied_for_user(self, user_id: int):
        """
        Checks tied channel to user
        """
        user_channel = {v: k for k, v in self.cache.items()}
        try:
            user_channel[user_id]
            return user_channel[user_id]
        except KeyError:
            return False
        return False

    def check_tied_for_channel(self, channel_id: int):
        """
        Checks tied user to channel
        """
        channel_user = self.cache
        try:
            channel_user[channel_id]
            return channel_user[channel_id]
        except KeyError:
            return False
        return False

Uses a cache based upon cog loading:

    async def _update_cache(self):
        """
        Update cache with config information
        """
        await self.bot.wait_until_red_ready()
        for guild in self.bot.guilds:
            category = await self.config.guild(guild).category()
            if category:
                chan = await self.bot.fetch_channel(category)
                for channel in chan.channels:
                    user = await self.config.channel(channel).user()
                    if user:
                        self.cache.update({channel.id: user})

So, either we add onto this cache system and make slight adjustments or we hook into another self function for the other options. No clue, something to think on how to incorporate.

[MailSystem] Embeds or Messages

There is a command that lets servers decide if they want an embed or message to be sent to and from users.

I have yet to handle the full functionality, I have two small functions which handle these. One handles the message for staff, the other handle whether it is an embed or message., but I've not incorporated them yet into the commands yet. Another function needs to be added to handle the user's side if it'll be a message.

The two functions are:

    async def returning_content(self, ctx: commands.Context, contents: str, anonymous: bool):
        """
        A regular message that gets sent to either staff or user
        """
        if anonymous:
            return f"**Anonymous Staff: {contents}**"
        else:
            return f"**{ctx.author.name}: {contents}**"

    async def _return_embed_or_content(self, ctx) -> bool:
        context = await self.config.guild(ctx.guild).embed_embeds()
        return True if context else False

Not reacting/Claiming

Apparently something I did messed up the code to not react nor claim. Looking into it now.

Rework Lockdown

Idea: Wanting to check for default role perms, if the role is denied for sending/joining then it'll immediately unlock. Therefore we don't have to have multiple commands for something simple. If this is possible, it'll reduce commands by a lot.

[MailSystem] Proper try/excepts cache func

I realized after a quick surf that I failed to have proper try/except checks in the cache function (_update_cache), which it'll error if the channel is not seen.

If someone would want to work on this, please feel free to.

Few things to look at:

  • Attempt to get channel first, if failed try/except on fetching the channel.
  • If failed on fetch, remove from config.

[StrawPoll] New configs

Planning to allow for more customize options, possibly setting to decide if the long rundown of commands and then look into specifics flag arguments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.