public ReactionRoleCommands(InteractivityService interactivity, IGuildConfigRepository repo, ILoggingService logging, DiscordSocketClient client, ReactionRoleService rrService, IReactionRoleRuleRepository rrRepo)
 {
     logging.Info("Initialising Reaction Role Command Service");
     _interactivity = interactivity;
     _repo          = repo;
     _rrService     = rrService;
     _rrRepo        = rrRepo;
     _logging       = new SourcedLoggingService(logging, "RRCmds");
     _client        = client.Rest;
 }
        public static async Task MessageReactionAddedEventHandlerAsync(TheGodfatherBot bot, MessageReactionAddEventArgs e)
        {
            if (e.Guild is null || e.Channel is null || e.Message is null)
            {
                return;
            }

            StarboardService ss = bot.Services.GetRequiredService <StarboardService>();

            if (ss.IsStarboardEnabled(e.Guild.Id, out ulong cid, out string star) && cid != e.Channel.Id && e.Emoji.GetDiscordName() == star)
            {
                LogExt.Debug(bot.GetId(e.Guild.Id), "Reacted with star emoji: Message {MessageId}, {Guild}", e.Message.Id, e.Guild);
                ss.RegisterModifiedMessage(e.Guild.Id, e.Channel.Id, e.Message.Id);
            }

            ReactionRoleService rrs = bot.Services.GetRequiredService <ReactionRoleService>();
            ReactionRole?       rr  = await rrs.GetAsync(e.Guild.Id, e.Emoji.GetDiscordName());

            if (rr is { })
Esempio n. 3
0
        public async Task MainAsync()
        {
            if (!LoadBotDefinition())
            {
                throw new Exception("No token provided.");
            }

            guildsDefinition = new GuildsDefinition();

            client = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel         = LogSeverity.Info,
                MessageCacheSize = 100
            });

            client.Log   += Log;
            client.Ready += OnReadyAsync;

            lavaConfig = new LavaConfig();
            lavaNode   = new LavaNode(client, lavaConfig);

            reactionRoleService = new ReactionRoleService(client, guildsDefinition);

            commandService = new CommandService();
            commandHandler = new CommandHandler(BuildServiceProvider(), client, commandService, botDefinition);

            await commandHandler.InstallCommandsAsync();

            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            await client.SetGameAsync(botDefinition.GetCurrent().status, null, ActivityType.Playing);

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
Esempio n. 4
0
 public ReactionRoleModule(RootController root, ReactionRoleService reactionRoleService) : base(root)
 {
     _reactionRoleService = reactionRoleService;
 }
Esempio n. 5
0
 public ReactionRoleModule(DiscordSocketClient client, GuildsDefinition guildsDefinition, ReactionRoleService roleService)
 {
     this.client           = client;
     this.guildsDefinition = guildsDefinition;
     this.roleService      = roleService;
 }