コード例 #1
0
        private async Task CloseThread(CommandArguments commandArgs, bool notify = true)
        {
            Match match = this.IdRegex.Match(commandArgs.Channel.Topic);

            if (!match.Success || !guid.TryParse(match.Value, out guid userId))
            {
                await commandArgs.SendReplySafe("This does not seem to be a modmail thread. This command can only be used in a modmail thread channel.");

                return;
            }

            await commandArgs.Channel.ModifyAsync(c => c.CategoryId = this.Client.Config.ModmailArchiveCategoryId);

            SocketCategoryChannel category = commandArgs.Channel.Guild.GetCategoryChannel(this.Client.Config.ModmailArchiveCategoryId);

            while ((category?.Channels.Count ?? 0) > this.Client.Config.ModmailArchiveLimit)
            {
                SocketGuildChannel oldChannel = category.Channels.OrderBy(c => c.Id).FirstOrDefault();
                if (oldChannel == null)
                {
                    break;
                }
                await oldChannel.DeleteAsync();
            }

            if (notify)
            {
                await SendModmailPm(commandArgs, userId, "Thread closed. You're welcome to send another message, should you wish to contact the moderators again.");
            }
        }
コード例 #2
0
ファイル: Greetings.cs プロジェクト: DaavidM/Discord-Bot
        public async Task DeleteChannel(SocketGuildChannel channelName)
        {
            await channelName.DeleteAsync();

            var user = Context.User as SocketGuildUser;

            await ReplyAsync($"{user.Mention} has deleted the Channel **{channelName}**.");
        }
コード例 #3
0
        public async Task Update(IBotwinderClient iClient)
        {
            BotwinderClient client    = iClient as BotwinderClient;
            ServerContext   dbContext = ServerContext.Create(client.DbConnectionString);
            bool            save      = false;
            DateTime        minTime   = DateTime.MinValue + TimeSpan.FromMinutes(1);

            //Channels
            List <ChannelConfig> channelsToRemove = new List <ChannelConfig>();

            foreach (ChannelConfig channelConfig in dbContext.Channels.Where(c => c.Temporary))
            {
                Server server;
                if (!client.Servers.ContainsKey(channelConfig.ServerId) ||
                    (server = client.Servers[channelConfig.ServerId]) == null)
                {
                    continue;
                }

                //Temporary voice channels
                SocketGuildChannel channel = server.Guild.GetChannel(channelConfig.ChannelId);
                if (channel != null &&
                    channel.CreatedAt < DateTimeOffset.UtcNow - this.TempChannelDelay &&
                    !channel.Users.Any())
                {
                    try
                    {
                        await channel.DeleteAsync();

                        channelConfig.Temporary = false;
                        channelsToRemove.Add(channelConfig);
                        save = true;
                    }
                    catch (Exception) { }
                }
                else if (channel == null)
                {
                    channelConfig.Temporary = false;
                    channelsToRemove.Add(channelConfig);
                    save = true;
                }
            }

            if (channelsToRemove.Any())
            {
                dbContext.Channels.RemoveRange(channelsToRemove);
            }

            if (save)
            {
                dbContext.SaveChanges();
            }
            dbContext.Dispose();
        }
コード例 #4
0
ファイル: Utility.cs プロジェクト: SinSiXX/Kaguya
        public async Task GuildDeleteTextChannel(SocketGuildChannel channel)
        {
            foreach (var Channel in Context.Guild.TextChannels)
            {
                if (Channel == channel)
                {
                    await channel.DeleteAsync();

                    embed.WithDescription($"{Context.User.Mention} has successfully deleted the text channel {(channel.Name)}.");
                    embed.WithColor(Pink);
                    BE(); return;
                }
            }
        }
コード例 #5
0
        public async Task GuildDeleteTextChannel(SocketGuildChannel channel)
        {
            stopWatch.Start();
            foreach (var Channel in Context.Guild.TextChannels)
            {
                if (Channel == channel)
                {
                    await channel.DeleteAsync();

                    embed.WithDescription($"{Context.User.Mention} has successfully deleted the text channel {(channel.Name)}.");
                    embed.WithColor(Pink);
                    await BE(); stopWatch.Stop();
                    logger.ConsoleCommandLog(Context, stopWatch.ElapsedMilliseconds); return;
                }
            }
        }
コード例 #6
0
        private async Task BackgroundTempChannelExpiryCheck(SocketGuild g, GuildInformation info)
        {
            SocketGuildChannel ch = null;

            lock (info)
            {
                ch = info.GetTemporaryChannel(g);
                if (ch == null)
                {
                    return;             // No temporary channel. Nothing to do.
                }
                if (!info.IsTempChannelExpired())
                {
                    return;
                }

                // If we got this far, the channel's expiring. Start the voting cooldown.
                info.Voting.StartCooldown();
            }
            await ch.DeleteAsync();
        }
コード例 #7
0
 public virtual Task DeleteAsync(RequestOptions?options = null)
 {
     return(_socketGuildChannel.DeleteAsync(options));
 }