module NeonRAW::Objects::Subreddit::Moderation
Methods for moderators.
Public Instance Methods
Accept a pending mod invite to the subreddit. @!method accept_mod_invite!
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 120 def accept_mod_invite! params = { api_type: 'json' } path = "/r/#{display_name}/api/accept_moderator_invite" @client.request_data(path, :post, params) refresh! end
Edit the subreddit's stylesheet. @!method edit_stylesheet
(data, opts = {}) @param data [String] The CSS for the stylesheet. @param opts [Hash] Optional parameters. @option opts :reason [String] The reason for the edit (256 characters
maximum).
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 183 def edit_stylesheet(data, opts = {}) params = { api_type: 'json', op: 'save', reason: opts[:reason], stylesheet_contents: data } path = "/r/#{display_name}/api/subreddit_stylesheet" @client.request_data(path, :post, params) end
@!group Listing
Fetches the modlog for the subreddit. @!method modlog(params = { limit: 25 }) @param params [Hash] The parameters. @option params :after [String] Fullname of the next data block. @option params :before [String] Fullname of the previous data block. @option params :count [Integer] The number of items already in the
listing.
@option params :limit [1..500] The number of listing items to fetch. @option params :mod [String] The moderator to filter actions by. Also
'a' can be given to filter by admin actions.
@option params :show [String] Literally the string 'all'. @option params :type [String] The type of mod action to filter by
[banuser, unbanuser, removelink, approvelink, removecomment, approvecomment, addmoderator, invitemoderator, uninvitemoderator, acceptmoderatorinvite, removemoderator, addcontributor, removecontributor, editsettings, editflair, distinguish, marknsfw, wikibanned, wikicontributor, wikiunbanned, wikipagelisted, removewikicontributor, wikirevise, wikipermlevel, ignorereports, unignorereports, setpermissions, setsuggestedsort, sticky, unsticky, setcontestmode, unsetcontestmode, lock, unlock, muteuser, unmuteuser, createrule, editrule, deleterule]
@return [NeonRAW::Objects::Listing] Returns a listing of the modlog
actions.
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 34 def modlog(params = { limit: 25 }) path = "/r/#{display_name}/about/log" @client.send(:build_listing, path, params) end
Fetches the subreddit's modmail. @!method modmail(params = { limit: 25 }) @param params [Hash] The parameters. @option params :after [String] Fullname of the next data block. @option params :before [String] Fullname of the previous data block. @option params :count [Integer] The number of things already in the
listing.
@option params :limit [1..1000] The number of listing items to fetch. @option params :only [Symbol] Only fetch either [links, comments]. @option params :show [String] Literally the string 'all'. @return [NeonRAW::Objects::Listing] Returns a listing with all the
things.
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 51 def modmail(params = { limit: 25 }) path = "/r/#{display_name}/about/message/inbox" @client.send(:build_listing, path, params) end
Remove a subreddit image. @!method remove_image!(image) @param image [String] The name of the image.
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 170 def remove_image!(image) params = { api_type: 'json', img_name: image } path = "/r/#{display_name}/api/delete_sr_img" @client.request_data(path, :post, params) refresh! end
Fetches the settings for the subreddit. @!method settings @return [Hash] Returns the subreddit's settings.
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 193 def settings path = "/r/#{display_name}/about/edit" @client.request_data(path, :get)[:data] end
Upload a subreddit image. @!method upload_image!(file_path, file_type, image_name, upload_type) @param file_path [String] The path to the file (500 KiB maximum). @param file_type [String] The file extension [png, jpg]. @param image_name [String] The name of the image. @param upload_type [String] The type of upload [img, header, icon,
banner].
# File lib/NeonRAW/objects/subreddit/moderation.rb, line 145 def upload_image!(file_path, file_type, image_name, upload_type) params = { img_type: file_type, name: image_name, upload_type: upload_type } path = "/r/#{display_name}/api/upload_sr_img" file = File.open(file_path, 'r') @client.request_data(path, :post, params, file: file) refresh! end